Article 5037 of comp.sys.handhelds: Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!sdd.hp.com!hplabs!hplred!seroussi From: seroussi@hplred.HP.COM (Gadiel Seroussi) Newsgroups: comp.sys.handhelds Subject: fmt48: a formatting/translation utility for the HP48SX Message-ID: <6230003@hplred.HP.COM> Date: 12 Mar 91 18:59:52 GMT Organization: Hewlett Packard Labs, Palo Alto CA Lines: 612 Attached to the end of the note is the uuencoded source of a program fmt48.c (V 0.05). This is a hack I wrote several months ago to "beautify" HP48 listings (I didn't like the format produced when downloading programs/vars/directories from the HP48 to the PC). With some modifications, the program now also translates HP48 listings to the ".app" format liked by PDL. Two formats are automatically recognized: 1. DIR format: DIR var1 obj1 var2 obj2 ... varn objn END 2. "Packed" format: \<< 'var1' obj1 SWAP STO 'var2' obj2 SWAP STO ... 'varn' objn SWAP STO \>> The "packed" format where the name follows the object is NOT recognized. The program consists of a single file, and it should compile properly under any reasonable C compiler. Fmt48 does a recursive PARTIAL parsing of the HP48 user language syntax, but it is not perfect. The following is a list of known bugs: 1) Max single token < 9000 bytes ( > 4 default size GROBS). Will fail for huge GROBS, strings, etc. 2) May fail for C$ strings with embedded newlines. 3) Does not handle paths correctly when a directory is embedded in a non-directory object; e.g. DIR pgm \<< DIR a 1 END \>> END 4) Does not remove "SWAP STO" from "packed" files. 5) May fail for Library objects; e.g. DIR lib Library 1234: DUMMY LIBRARY END fails, but DIR liblist { Library 1234: DUMMY LIBRARY } END works. DISCLAIMERS, WARRANTIES, GUARANTEES: the program is guaranteed to be bug-ridden, and to fail when you most need it. Other than that, no guarantees or warranties, implicit or explicit. I work for HP, but this was done on my free time, and the company has nothing to do with it. WARNING: ALWAYS KEEP A COPY OF YOUR ORIGINAL FILE UNTIL YOU ARE 100% CONVINCED THAT FMT48 DID NOT MESS IT UP IN THE PROCESS OF FORMATTING IT. REMEMBER: THIS IS VERSION 0.5 OF A HACK. Usage: the following is printed when you type "fmt48 -h": FMT48 V. 0.5 usage: fmt48 [ flags ] [ filein ] [ fileout ] Flags: -a : Format PDL `.app' file. -t : Translate HP48 DIR or `packed' file to PDL `.app' file. -n : Put quoted names on separate lines (for `transapp'). -d"path": Set root directory to `path'. -T : Translate characters 0-31 (except 10, 13) and 127-255 to escape sequences \ddd. -l: Set output line length (w/o comments) to (default = 50). -i: Set indent increment to (default = 2). -I: Set comment indent to (default = 52). -q : Quiet mode: do not add comments to DIR files. Files: filein : input file (default = stdin). fileout: output file. Defaults: If filein=stdin then fileout=stdout, if filein=name.ext, and -t was not specified, then fileout=name.f48, if filein=name.ext, and -t was specified, then fileout=name.app. When no translations are specified, the program just formats a downloaded HP48 file. All input files must have been transferred with translation mode 3. Gadiel Seroussi -------------------------Cut here---------------------------------------- begin 777 fmt48.c M+RH*("H@9FUT-#@Z(&$@2% T.%-8(&9O2 @5BX@,"XU+@H@*@H@*B H8RD@,3DY,"P@,3DY,2!'861I96P@ M4V5R;W5S2!W87DL(&)U="!N;W0@9F]R(&-O;6UE2 *9G)E92!T:6UE+"!A;F0@=&AE(&-O;7!A;GD@:&%S(&YO=&AI;F<@=&\@ M9&\@=VET:"!I="X*"B J+PH*"B-I;F-L=61E(#QS=&1I;RYH/@HC:6YC;'5D M92 \"D]/4Q)3D5?0T]-345.5"E\?%P*(" @(" @(" @ M(" @(" @(" @(" @(" @*"AX*3T]4$1,7T-/34U%3E0I?'PH*'@I/3U-3T1% M4U]#3TU-14Y4*2 I"@HC9&5F:6YE(%1"1%]-3T1%( DQ"B-D969I;F4)1$E2 M7TU/1$4),@HC9&5F:6YE(%!!0TM%1%]-3T1%"3,*"F5N=6T)=&]K96Y?='EP M92![($]42$52+" *"0D@(" @($Q01TTL(%)01TTL($Q#55),+"!20U523"P@ M"@D)(" @("!,3T-!3%]$5D%2+ H)"2 @(" @1%%53U0L($Q$455/5"P@4D11 M54]4+ H)"2 @(" @4U%53U0L($Y!344L($Q3455/5"P@4E-154]4+ H)"2 @ M(" @0U-44DE.1RP*"0D@(" @($Q"4DM4+"!20E)+5"P@"@D)(" @("!$3$)2 M2U0L($120E)+5"P@1$E2+" *"0D@(" @($E&+"!)1D524BP@5$A%3BP@14Q3 M12P@14Y$+"!#05-%+ H)"2 @(" @5TA)3$4L(%)%4$5!5"P*"0D@(" @($1/ M+"!53E1)3"P*"0D@(" @($9/4BP@4U1%4"P@3D585"P*"0D@(" @(%-405)4 M+ H)"2 @(" @4TA!4E L"@D)(" @("!'4D]"+ H)"2 @(" @1$E6241%+ H) M"2 @(" @0T]-345.5"P*"0D@(" @($Q)3D5?0T]-345.5"P*"0D@(" @($U/ M1$537T-/34U%3E0L"@D)(" @("!01$Q?0T]-345.5"P*"0D@(" @($Q)3DM% M1"P@05)205DL"@D)(" @("!,3TY'+"!214%,+"!#3TU03$58+ H)"2 @(" @ M3$E"4D%262P@1$%402P*"0D@(" @($5/3"P*"0D@(" @($Q!4U1?5$]+14X* M"0D@("!].PH*='EP961E9B!S=')U8W0@>PH)8VAA7!E('1Y<&4["@EI;G0@(&EN9&5N=%]B969O"P@+RH@:6YD97@@9F]R(&YE7!E"0EI M;F1?8F5F(&EN9%]A9B @;FQ?8F5F("!N;%]A9G0@:6YD>"!D96QT82 J+PH* M>R)<7#P\(BP@"4Q01TT@+ D),"P),2P)3DQ)3D4L"4Y,24Y%+%)01TTL(" Q M?2P*>R)<7#X^(BP@"5)01TT@+ D)+3$L"3 L"4Y,24Y%+ E.3$E.12Q24$=- M+" M,7TL"GLB>R(L(" @( E,0U523"P)"3 L"3 L"3 L"3 L(" @(%)#55), M+" Q?2P*>R)](BP)"5)#55),+ D),"P),"P),"P),"P@(" @4D-54DPL+3%] M+ I[(B=D=F%R(BP)3$]#04Q?1%9!4BP),"P),"P),"P),"P@(" @3$]#04Q? M1%9!4BP@,'TL"GLB7"(B+ D)1%%53U0L"0DP+ DP+ DP+ DP+" @("!$455/ M5"P@,7TL"GLB7"(B+ D)3$1154]4+ D@"3 L"3 L"3 L"3 L(" @($1154]4 M+" Q?2P*>R)<(B(L"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0DP+ DQ+ E.3$E.12P) M3DQ)3D4L3D585"P@(#%]+ I[(D=23T(B+ E'4D]"+ D),"P),"P),"P),"P@ M(" @1U)/0BP@(#-]+ I[(B\B+ D)1$E6241%+ D),"P),"P),"P),"P@(" @ M1$E6241%+" @,'TL"GLB3&EN:V5D(BP)3$E.2T5$+ D),"P),"P),"P),"P@ M(" @05)205DL(#%]+ I[(D%R2(L"4Q)0E)!4EDL"3 L"3 L"3 L"3 L(" @ M($1!5$$L(" Q?2P*>R)$871A(BP)1$%402P)"3 L"3 L"3 L"3 L(" @($1! M5$$L("TQ?2P*>R) (BP)"4-/34U%3E0L"3 L"3 L"3 L"4Y,24Y%+$]42$52 M+" P?2P*>R) (BP)"4Q)3D5?0T]-345.5"P),"P),"P)3DQ)3D4L"4Y,24Y% M+$]42$52+" P?2P*>R(E)4A0.B(L"4U/1$537T-/34U%3E0L"3 L"3 L"4Y, M24Y%+ E.3$E.12Q/5$A%4BP@,'TL"GLB+R(L"0E01$Q?0T]-345.5"P),"P) M,"P)3DQ)3D4L"4Y,24Y%+$]42$52+" P?2P*>R(C(BP)"5-(05)0+ D),"P) M,"P),"P),"P@(" @1U)/0BP@(#%]+ I[(EQN(BP)"45/3" @+ D),"P),"P) M,"P),"P@(" @3U1(15(L(#!]+ I[(B(L"0E/5$A%4BP)"3 L"3 L"3 L"3 L M(" @($]42$52+" P?2P*>TY53$PL"0E,05-47U1/2T5.+ D)?0I].PH*+RH@ M8W)O'0["GT["@HO*B!H M96%D(&9OPH)1DE,12 J9FEN("P* M"2 @(" @*F9O=70@/2!S=&1O=70["@EC:&%R("II;F9I;&5N86UE(#T@3E5, M3"P*"2 @(" @*F9I;&5?PH)"0ES=VET8V@@*"!APH) M"0D)8V%S92 G9"PH)"0D)"0EU&ET*#$P*3L*"0D)"0E] M"@D)"0D)8G)E86L["@H)"0D)8V%S92 G:2PH)"0D)"0EU M&ET*#$P*3L*"0D)"0E]"@D)"0D)8G)E86L["@H) M"0D)8V%S92 G22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)"2 @(" O M*B!N;W1H:6YG('-P96-I86P@86)O=70@=&AI5]T;VME;B ](# ["@H)"6EF("@@=&MN+3YT>7!E(#T]($1)4B I('L* M"0DO*B!P2 J+PH)"0EU<&1A=&5?;F5S M=&EN9RAT:VXL("9N97-T8RD["@D)"2\J(&%D9"!D:7(@;F%M92 H:68@86YY M*2!T;R!P871H("HO"@D)"6EF("@@<&%T:" ]/2!.54Q,("D*"0D)"7-T2AL87-T M7VYA;64L('1K;BT^PH)"0D) M"0DO*B!$25(M/D%04"!T2 J+PH)"0D)"2\J(&-H96-K(&EF('1H:7,@:7,@=&AE(&]U=&5R($5. M1"!I;@H)"0D)"2 @(&$@1$E2(&9I;&4@8F5I;F<@=')A;G-L871E9"!T;R * M"0D)"0D@("!@+F%P<"'!E8W1E9"!N M86UE+"!G;W0@)7,@*&QI;F4@)60I7&XB+"!T:VXM/G-T%T@+2T["@D)"0D);F5S=&,N=&]T86Q?;F5S=&EN9R M+3L*"0D)"7T*"0D) M"65LPH)"0D)"6YE"!.97<@8W1R+CTE9"!4;W1A;"!N97-T/25D7&XB+ H)"0ET:VXM/G-T MPH) M'0@*2!["@D):68@*" J*' M/FYA;64I("8F("@@ M;&5N("L@PH)"69P6EN9R!T;R!R M96UO=F4@9G)O;2!A;B!E;7!T>2!P871H7&XB*3L*"0ER971U'0@(3T@3E5,3#L@<#(@ M/2!P+"!P(#T@<"T^;F5X=" I.PH*"69R964H<"T^;F%M92D["@EF'0@/2!.54Q,.PH)96QS90H)(" @ M("IP871H<" ]($Y53$P[(" @+RH@96UP=&EE9"!T:&4@=VAO;&4@;&ES=" J M+PH)PH*"71O:V5N7VYO9&4@*G1K;C(["@EC M:&%R(" @("IT;VLL("IR96%D7W1O:V5N*"D["@H):68@*" H=&]K(#T@2!I;B!M=6QT:2UL:6YE('1O:V5NR @(" O*B!R96%D(&YE=R!L:6YE("HO"@D):68@*"!G971?;&EN92AI;G!? M;&EN92QF<"D@/3T@3E5,3" I"@D)"7)E='5R;B!.54Q,.PH)"6EN<%]L:6YE M8V]U;G0@*RL["@D);F5W;&EN92 ](# ["@D);' @/2!I;G!?;&EN93L*"@D) M+RH@9&5T96-T(&9U;&PM;&EN92!C;VUM96YTR @(" @+RH@<75O M=&5D('-T2AT M;VME;BP@(EPB(BD["@D);' K*SL*"0EW:&EL92 H("AL<#(@/2!S=')C:'(H M;' L("'1?;F]NPH)9F]R("@@.R J;' @)B8@ M*'-TPH)PH)"69L=7-H7VQI M;F4H(&]U=%]L:6YE+"!I;F1T7VQE=F5L+"!N97=L:6YE+"!F<"D["@D);F5W M;&EN92 ](#$["@E]"@H):68@*"!T:VXM/G1Y<&4@(3T@14],("D@>PH)(" @ M(&EF("@@(&YE=VQI;F4@)B8@=&ML96XK7!E(#T](%!$3%]#3TU-14Y4("D@>PH)"2\J(&1O(&YO="!I;F1E;G0@ M*B\*"0ES=')C<'DH;W5T7VQI;F4L('1O:RD["@D)9&]?9FQU7!E(#T]($1)5DE$12 F)B!S=')L96XH;W5T7VQI;F4I(#T] M(# @*0H)"2\J(&UA:V4@65D7V%F=&5R M('Q\("AT:VXM/FYL7V%F=&5R(#T]($Y,24Y%*2!\?"!D;U]F;'5S:" I('L* M"0EF;'5S:%]L:6YE*&]U=%]L:6YE+"!I;F1T7VQE=F5L+" P+"!F<"D["@D) M;F5W;&EN92 ](#$["@D)9&5L87EE9%]A9G1E65D7V%F=&5R(#T@,3L*"7T*?0H*9FQU2P@9G I"F-H87(@*FQI;F4["FEN=" @:6YD=%]L979E;"P@:6YI=%]O M;FQY.PI&24Q%("IF<#L*>PH):6YT(&D["@H):68@*" A:6YI=%]O;FQY("D* M"0EF<')I;G1F*&9P+"(EPH)=&]K96Y?;F]D92 J M=&MP.PH):6YT(" @(" @("!T:VQE;CL*"6-H87()(" @9FER')E9EM,24Y%7T-/34U%3E1=.PH*"0EC87-E("= )SH* M"0D@(" @F5D+@H) M*B\*"6EF("@@9FER')E9EM/5$A%4ET["@D) M96QS90H)"0ER971U')E9EM,1%%53U1=.PH*"6EF("@@;&%S M=" ]/2 G(B<@)B8@=&ML96X@/B Q("D*"0ER971U')E9EM2 M1%%53U1=.PH)"@EI9B H(&9I')E9EM. M04U%73L*"0EE;'-E"@D)"7)E='5R;B!T;VME;E]X2AI;G!?;&EN92P@=&UP M;&EN92P@24Y?3$E.14Q%3BD["@ER971UPH)"0D)9G!R:6YT9BAS=&1EPH)"0EI M9B H(&P@*R Q(#X@;&5N("D@>PH)"0D)9G!R:6YT9BAS=&1E&-E<'0@,3 L(#$S*2!A;F0@,3(W+3(U-2!T;UQN7 H@(" @(" @ M(" @97-C87!E('-E<75E;F-E