[File] [PATCH] Magdir/printer Hewlett-Packard Graphics Language misidentfies QEMU shell scripts +
Christos Zoulas
christos at zoulas.com
Fri Jun 16 19:27:22 UTC 2023
Committed, thanks!
christos
> On Jun 3, 2023, at 3:44 PM, Jörg Jenderek (GMX) <joerg.jen.der.ek at gmx.net> wrote:
>
> Hello,
>
> some days ago (16.12.2022) i send patch of Magdir/printer to recognize
> Hewlett-Packard Graphics Language which typically have file suffix
> like hpgl/hpg/hp. When running file command version 5.44 on such samples
> and related misidentified files i get an output like:
>
> Linux-syscall-note:
> Hewlett-Packard Graphics Language, starting with
> "SPDX-Exception-Identifier: Linux-syscall-note"
> with "SPDX-URL: "
> miter.hp:
> Hewlett-Packard Graphics Language, starting with
> "PA4000,3000;" with "PW2;\012LA"
> test3.hpgl:
> Hewlett-Packard Graphics Language, starting with
> "SP6;DI0,1;SR0.70,1.90;SC0,800,0,576;PA;PU20,0;LBDSA 60"
> with "SP3;SC-864"
> test_msa_run_32r5eb.sh:
> Hewlett-Packard Graphics Language, starting with
> "PATH_TO_QEMU="../../../../../../mips-linux-user/qemu-m"
>
> Obviously the Hewlett-Packard Graphics have no unique magic pattern.
> But luckily the displaying part is done by sub routine hpgl inside
> Magdir/printer which start like:
> 0 name hpgl
> >0 string x Hewlett-Packard Graphics Language
> !:mime application/vnd.hp-HPGL
> !:ext hpgl/hpg/hp/plt
> >0 string x \b, starting with "%-.54s"
> Luckily in output by phrase "starting with" the first line of file is
> shown. So this can be used for control reasons. So with this output i
> can check what is going wrong and i must insert some additional tests
> before calling the sub routine.
>
> I often have used about 2 bytes (that are 16 bits) for recognition.
> You can blame me for not using 32 bits, but i have not time to read and
> understand whole specification and get part time HP plotter expert. But
> now some collisions occur so i spent some time to refine test lines.
>
> So samples like test3.hpgl starting with Select Pen directive are done
> by lines like:
> 0 string SP
> >0 use hpgl
> According to documentation the argument is pen number n. This argument
> is integer. So it is in the range between -32767 and 32768. If there is
> no pen number or this 0, the controller performs an end of file command.
> Assuming that there exist no negative pen number such samples are now
> caught by lines like:
> 0 string SP
> >2 regex \^([0-9]{1,5})
> #>2 regex \^([0-9]{1,5}) PEN_NUMBER=%s
> >>0 use hpgl
> So for real HP samples like test3.hpgl i get pen number like 6. The text
> file Linux-syscall-note inside qemu sources start with line like:
> SPDX-Exception-Identifier: Linux-syscall-note
> So by current test it is identified as HPGL file. With the additional
> test line it is now skipped.
>
> Samples like miter.hp with Plot Absolute directive are done by lines like:
> 0 string PA
> >0 use hpgl
>
> According to documentation the arguments are coordinates x,y{,x,y{...}}.
> These arguments are integer. So these are in the range between -32767
> and 32768. So now i check also for valid x coordinate. So such samples
> are now caught by lines like:
> 0 string PA
> >2 regex \^([-]{0,1}[0-9]{1,5})
> #>2 regex \^([-]{0,1}[0-9]{1,5}) COORDINATE=%s
> >>0 use hpgl
> So for examples like miter.hp i get coordinate value 4000. Some shell
> scripts like test_msa_run_32r5eb.sh test_msa_run_32r5eb.sh inside qemu
> sources start with line like:
> PATH_TO_QEMU="../../../../../../mips-linux-user/qemu-m
> So by current test these script are identified as HPGL file. With the
> additional test line these scripts are now skipped.
>
> After applying the above mentioned modifications by patch
> file-5.44-printer-hpgl.diff then Hewlett-Packard Graphics samples are
> still described as before but misidentification vanish. This now looks like:
> Linux-syscall-note:
> ASCII text
> miter.hp:
> Hewlett-Packard Graphics Language, starting with
> "PA4000,3000;"
> with "PW2;\012LA"
> test3.hpgl:
> Hewlett-Packard Graphics Language, starting with
> "SP6;DI0,1;SR0.70,1.90;SC0,800,0,576;PA;PU20,0;LBDSA 60"
> with "SP3;SC-864"
> test_msa_run_32r5eb.sh:
> ASCII text
>
> With best wishes,
>
> Jörg Jenderek
> --
> Jörg Jenderek
> <file-5_44-printer-hpgl_diff.DEFANGED-2093><file-5_44-printer-hpgl_diff_sig.DEFANGED-2094>--
> File mailing list
> File at astron.com
> https://mailman.astron.com/mailman/listinfo/file
> <sanitizer.log>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <https://mailman.astron.com/pipermail/file/attachments/20230616/566f1044/attachment.asc>
More information about the File
mailing list