home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume21 / p2c / part05 < prev    next >
Encoding:
Internet Message Format  |  1990-04-05  |  42.0 KB

  1. Subject:  v21i050:  Pascal to C translator, Part05/32
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: 78c6d945 9e4c6d47 2a0dc08f b923e770
  5.  
  6. Submitted-by: Dave Gillespie <daveg@csvax.caltech.edu>
  7. Posting-number: Volume 21, Issue 50
  8. Archive-name: p2c/part05
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 5 (of 32)."
  17. # Contents:  HP/import/sysglobals.imp src/COPYING src/stuff.c
  18. # Wrapped by rsalz@litchi.bbn.com on Mon Mar 26 14:29:29 1990
  19. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  20. if test -f 'HP/import/sysglobals.imp' -a "${1}" != "-c" ; then 
  21.   echo shar: Will not clobber existing file \"'HP/import/sysglobals.imp'\"
  22. else
  23. echo shar: Extracting \"'HP/import/sysglobals.imp'\" \(13046 characters\)
  24. sed "s/^X//" >'HP/import/sysglobals.imp' <<'END_OF_FILE'
  25. X
  26. X
  27. X{IncludeFrom=sysglobals <p2c/sysglobals.h>}
  28. X
  29. X
  30. X{*VarStrings=1} {*ExportSymbol=}
  31. X
  32. X
  33. Xmodule sysglobals;  
  34. X
  35. Xexport 
  36. X
  37. Xtype fsidctype = packed array[1..20] of char; 
  38. Xconst 
  39. X  fsidc = fsidctype['Rev.  3.1  18-Jul-85'];   
  40. X                             (*20 CHARS: VERSION,DATE,TIME OF FILE SYS*)
  41. X  mminint = -32768;          (*MINIMUM SHORT INTEGER VALUE*)
  42. X  mmaxint =  32767;          (*MAXIMUM SHORT INTEGER VALUE*)
  43. X  maxunit = 50;              (*MAXIMUM PHYSICAL UNIT NUMBER*)
  44. X  passleng = 16;             (*NUMBER OF CHARS IN A PASSWORD*)
  45. X  vidleng = 16;              (*NUMBER OF CHARS IN A VOLUME NAME*)
  46. X  tidleng = 16;              (*NUMBER OF CHARS IN A FILE TITLE*)
  47. X  fidleng = 120;             (*NUMBER OF CHARS IN FILE NAME*)
  48. X  fblksize = 512;            (*STANDARD FILE BUFFER LENGTH*)
  49. X  maxsc=63;                  (*LARGEST SELECT CODE *)
  50. X  minlevel=1;                (*LOWEST INTERRUPT LEVEL*)
  51. X  maxlevel=6;                (*LARGEST MASKABLE INTERRUPT LEVEL*)
  52. X      
  53. X  
  54. Xtype  
  55. X
  56. X  byte = 0..255; 
  57. X  shortint = mminint..mmaxint;  
  58. X  ipointer = ^integer;
  59. X  charptr = ^char;
  60. X  textpntr = ^text; 
  61. X  string80 = string[80];
  62. X  string255 = string[255];
  63. X  suffixtype = string[5];
  64. X  string255ptr = ^string255; 
  65. X
  66. X                                                              
  67. X  unitnum = 0..maxunit; 
  68. X  vid = string[vidleng]; 
  69. X  tid = string[tidleng];
  70. X  fid = string[fidleng];
  71. X  passtype = string[passleng];
  72. X
  73. X  filekind = (untypedfile,      {directory entry} 
  74. X              badfile,          {bad blocks}
  75. X              codefile,         {executable or linkable}
  76. X              textfile,         {UCSD format text with editor environment}
  77. X              asciifile,        {L.I.F. ASCII format text strings}
  78. X              datafile,         {file of  <data type, e.g. char, integer,etc.>}
  79. X              sysfile,          {system (BOOT) file}
  80. X     fkind7,  fkind8,  fkind9,  
  81. X     fkind10, fkind11, fkind12, 
  82. X     fkind13, fkind14, lastfkind);      {reserved for future expansion}
  83. X
  84. X  
  85. X                                                           (*FILE INFORMATION*)
  86. X
  87. Xwindow = packed array [0..maxint] of char;
  88. Xwindowp = ^window;
  89. X
  90. X
  91. Xfibp = ^fib;
  92. X
  93. Xamrequesttype = (readbytes, writebytes, flush, writeeol, readtoeol, clearunit, 
  94. X          setcursor, getcursor, startread, startwrite, unitstatus, seekeof); 
  95. Xamtype = procedure (fp: fibp; request: amrequesttype; 
  96. X                           anyvar buffer: window; bufsize, position: integer); 
  97. Xeotproc = procedure(fp: fibp); 
  98. X
  99. Xfib = packed record 
  100. X           fwindow: windowp;                         (*BUFFER VARIABLE...F^ *)
  101. X           flistptr: fibp;                            (* LIST OF OPEN FILES *)
  102. X       {declaration and type information}
  103. X           frecsize: integer;                 (* SIZE OF ONE LOGICAL RECORD *)
  104. X           feft: shortint;                            (* EXTERNAL FILE TYPE *)
  105. X           fkind: filekind;                                    (* FILE KIND *)
  106. X           fistextvar:  boolean;                  (* FILE IS LINE FORMATTED *)
  107. X           fbuffered:   boolean;               (* HAS 512 BYTE BLOCK BUFFER *)
  108. X           fanonymous: boolean;                         (* FILE HAS NO NAME *)
  109. X           fisnew:  boolean;                (* WAS CREATED THIS ASSOCIATION *)
  110. X           freadable, fwriteable: boolean;            (* FILE ACCESS RIGHTS *)
  111. X       {state information}
  112. X           freadmode, fbufvalid: boolean;         (*F^ AND LOOKAHEAD STATES *)
  113. X           feoln: boolean;                          (* F^ IS AN END OF LINE *) 
  114. X           feof: boolean;                 (* TRIED TO READ PAST END OF FILE *)
  115. X           fmodified: boolean;                     (* FILE HAS CHANGED SIZE *)
  116. X           fbufchanged: boolean;              (* BUFFER NEEDS TO BE WRITTEN *)
  117. X       {file size and position}
  118. X           fpos:  integer;           (* FILE POINTER, CURRENT FILE POSITION *)
  119. X           fleof: integer;         (*LOGICAL END OF FILE, CURRENT FILE SIZE *)
  120. X           fpeof: integer;        (*PHYSICAL END OF FILE, MAXIMUM FILE SIZE *)
  121. X       {buffering and low level formatting information}
  122. X           flastpos:  integer;                   (* FILE POSITION OF BUFFER *)
  123. X           freptcnt:  shortint;                  (* SPACE COMPRESSION COUNT *)
  124. X           am:  amtype;                              (*BUFFER METHOD MODULE *)
  125. X       {file association info}
  126. X           fstartaddress: integer;         (*EXECUTION ADDRESS IN BOOT FILE *)
  127. X           fvid: vid;                                        (* VOLUME NAME *)
  128. X           ffpw: passtype;                                 (* FILE PASSWORD *)
  129. X           ftid: tid;                                          (* FILE NAME *)
  130. X           pathid:  integer;     (* ADDITIONAL SYSTEM DEPENDENT INFORMATION *)
  131. X           fanonctr: shortint;                      (* TEMP FILE IDENTIFIER *)
  132. X           foptstring: string255ptr;               (* OPTIONAL STRING PARAM *)
  133. X       {byte block transfer information}
  134. X           fileid:  integer; (* START BYTE OF FILE, OR OTHER IDENTIFICATION *)
  135. X           fb0,fb1,                                 (* FOR FUTURE EXPANSION *)
  136. X           fnosrmtemp,                   (*TRUE IF NO SRM TEMP FILE CREATED *)
  137. X           fwaitonlock,                  (*TRUE IF SRM SHOULD WAIT FOR LOCK *)
  138. X           fpurgeoldlink,            (*TRUE IF OLD SRM LINK IS TO BE PURGED *)
  139. X           foverwritten,                    (*TRUE IF OPENED WITH OVERWRITE *)
  140. X           fsavepathid,               (*TRUE IF PATHID NOT UNIQUE TO FILEID *)
  141. X           flockable,                     (*TRUE IF FILE OPENED AS LOCKABLE *)
  142. X           flocked,                                (*TRUE IF FILE IS LOCKED *)
  143. X           fbusy        : boolean;               (*TRUE IF DRIVER IS ACTIVE *)
  144. X           funit        : unitnum;                   (*PHYSICAL UNIT NUMBER *)
  145. X           feot         : eotproc;         (*CALLED WHEN TRANSFER COMPLETES *)
  146. X           fxpos        : integer;                (* X POSITION FOR  GOTOXY *)
  147. X           fypos        : integer;                (* Y POSITION FOR  GOTOXY *)
  148. X           foldfileid   : integer;    (* FILEID FOR OLD SRM FILE ON REWRITE *)
  149. X       {for future expansion}
  150. X           fextra:  array[0..2] of integer;
  151. X           fextra2: shortint;
  152. X       {large miscellaneous fields sometimes present}
  153. X           case integer of 
  154. X             0: ( {minimal FIB ends here} );
  155. X             1: (ftitle:  fid);        (* FILE NAME, EXCEPT VOLUME AND SIZE *)
  156. X             2: (fbuffer: packed array [0..fblksize-1] of char); 
  157. X        end (*FIB*) ;
  158. X
  159. X
  160. Xdamrequesttype = (getvolumename, setvolumename, getvolumedate, setvolumedate,  
  161. X changename, purgename, 
  162. X openfile, createfile, overwritefile, closefile, purgefile,
  163. X stretchit, makedirectory, crunch, opendirectory, closedirectory, catalog,
  164. X stripname, setunitprefix, openvolume, duplicatelink, openparentdir,
  165. X catpasswords,setpasswords,lockfile,unlockfile,openunit); 
  166. X  
  167. Xdamtype = procedure (anyvar f: fib; unum:unitnum; request: damrequesttype); 
  168. X  
  169. Xunitentry =  {unitable entry definition}
  170. X    packed record
  171. X      dam: damtype;                     {directory access method}
  172. X      tm:  amtype;                      {byte block transfer method}
  173. X      sc: byte;                         {select code}
  174. X      ba: byte;                         {bus address} 
  175. X      du: byte;                         {disc unit}  
  176. X      dv: byte;                         {disc volume}
  177. X      byteoffset: integer;              {physical starting byte of volume} 
  178. X      devid: integer;                   {identifier (Amigo identify sequence)} 
  179. X      uvid: vid;                        {volume id}
  180. X      dvrtemp: integer;                 {temp for driver use only; init to 0!}
  181. X      dvrtemp2: shortint;               {temp for driver use only; init to 0!}
  182. X      letter: char;                     {device specifier letter}
  183. X      offline,                          {unit absent or down flag}
  184. X      uisinteractive,                   {user can edit input}
  185. X      umediavalid,                      {medium not changed since last access}
  186. X      uuppercase:   boolean;            {volume name must be uppercased}
  187. X      uisfixed: boolean;                {fixed/removeable media flag}
  188. X      ureportchange: boolean;           {driver mode: report/ignore media change}
  189. X      pad: 0..1;                        {   (bit not used yet)  }
  190. X      case uisblkd: boolean of          {blocked volume flag}
  191. X        true: (umaxbytes: integer)      {volume size in bytes }
  192. X    end;  {unitentry}
  193. X    
  194. Xunitabletype = array [unitnum] of unitentry;                   (*0 NOT USED*)
  195. Xamtabletype  = array[filekind] of amtype; 
  196. Xsuftabletype = array[filekind] of suffixtype; 
  197. Xefttabletype = array[filekind] of shortint; 
  198. X
  199. Xunitableptr     = ^unitabletype;
  200. Xamtableptrtype  = ^amtabletype; 
  201. Xsuftableptrtype = ^suftabletype; 
  202. Xefttableptrtype = ^efttabletype; 
  203. X  
  204. X  
  205. Xiorsltwd = 
  206. X            { *note* the ioresult enumerations have been partitioned into two
  207. X              mutually-exclusive groups: those beginning with 'z' are reserved
  208. X              for the low-level drivers , and those beginning
  209. X              with 'i' are reserved for the higher-level routines.}
  210. X             
  211. X             (inoerror,zbadblock,ibadunit,zbadmode,ztimeout,
  212. X              ilostunit,ilostfile,ibadtitle,inoroom,inounit,
  213. X              inofile,idupfile,inotclosed,inotopen,ibadformat,
  214. X              znosuchblk,znodevice,zinitfail,zprotected,
  215. X              zstrangei,zbadhardware,zcatchall,zbaddma,
  216. X              inotvalidsize,inotreadable,inotwriteable,inotdirect,
  217. X              idirfull,istrovfl,ibadclose,ieof,
  218. X              zuninitialized,znoblock,znotready,znomedium,
  219. X              inodirectory,ibadfiletype,ibadvalue,icantstretch,
  220. X              ibadrequest, inotlockable, ifilelocked, ifileunlocked, 
  221. X              idirnotempty, itoomanyopen, inoaccess, ibadpass, ifilenotdir, 
  222. X              inotondir, ineedtempdir, isrmcatchall, zmediumchanged,
  223. X              {end marker} endioerrs);
  224. X  
  225. Xproctype=procedure;
  226. Xsctype=0..maxsc;
  227. Xleveltype=minlevel..maxlevel;
  228. Xpisrib = ^isrib;
  229. Xisrproctype = procedure(isribptr: pisrib);
  230. Xisrib = {isr information block}
  231. X   packed record
  232. X     intregaddr: charptr;       {interrupt register address}
  233. X     intregmask: byte;          {interrupt register mask}
  234. X     intregvalue: byte;         {interrupt register target value after masking}
  235. X     chainflag: boolean;        {chaining flag}
  236. X     proc: isrproctype;         {isr}
  237. X     link: pisrib;              {pointer to next isrib in linked list}
  238. X   end;
  239. Xinttabletype = array [1..7] of pisrib;
  240. X
  241. Xaction = procedure; 
  242. X
  243. Xdaterec         = packed record
  244. X                    year        : 0..100;       (*100 IS TEMP DISK FLAG*)
  245. X                    day         : 0..31;        (*DAY OF MONTH*)
  246. X                    month       : 0..12;        (*0 ==> DATE NOT MEANINGFUL*)
  247. X                  end; 
  248. X
  249. Xtimerec         = packed record
  250. X                    hour        : 0..23;
  251. X                    minute      : 0..59;
  252. X                    centisecond : 0..5999;
  253. X                  end; 
  254. X  
  255. Xdatetimerec     = packed record
  256. X                    date        : daterec;
  257. X                    time        : timerec;
  258. X                  end;
  259. X
  260. Xvar
  261. X(*========= MANY OF THE FOLLOWING HAVE HARDCODED
  262. X            ADDRESSES IN COMPILER AND ELSEWHERE  =====*)
  263. X       
  264. X(*** ERROR RECOVERY  ***)
  265. X  sysescapecode:        shortint; 
  266. X  openfileptr:  anyptr; 
  267. X  recoverblock: anyptr; 
  268. X  
  269. X(*** MEMORY MANAGEMENT ***)
  270. X  heapmax:      anyptr; 
  271. X  heapbase:     anyptr; 
  272. X  
  273. X(*** I/O DRIVERS ***)
  274. X  sysioresult:          integer; 
  275. X  hardwarestatus:       integer;
  276. X  locklevel:      integer; 
  277. X  unitable: unitableptr;
  278. X  interrupttable: inttabletype;
  279. X  endisrhook:  integer;
  280. X  actionspending: integer; 
  281. X  
  282. X(*** FILE SYSTEM ***)
  283. X  gfiles: array[0..5] of textpntr;    
  284. X  {  [0] INPUT          [3] (unused)
  285. X     [1] OUTPUT         [4] LISTING 
  286. X     [2] KEYBOARD       [5] (unused)   }
  287. X  
  288. X  amtable:     amtableptrtype;                  {pointer to access methods }
  289. X  suffixtable: suftableptrtype;                 {pointer to list of suffixes}
  290. X  efttable:    efttableptrtype;                 {pointer to LIF file types}
  291. X  sysunit: integer;
  292. X  syvid,dkvid: vid;                           (*SYSUNIT VOLID & DEFAULT VOLID*)
  293. X  syslibrary: fid; 
  294. X  
  295. X  (*** DEBUGGER HOOK ***)
  296. X  debugger: procedure(p1, p2, p3: integer); 
  297. X  
  298. X  (*** CLEAR I/O HOOK ***)
  299. X  cleariohook : procedure;    
  300. X  
  301. X  perminttable: inttabletype;
  302. X  
  303. X  deferredaction: array[1..10] of action; 
  304. X  
  305. X  serialtextamhook: amtype;             {access method for serial devices}
  306. X  
  307. X  sysname[-574]: packed array[1..10] of char; 
  308. X  
  309. X  sysflag[-302]: packed record
  310. X    reserved1, reserved2, nointhpib, crtconfigreg, 
  311. X    nokeyboard, highlightsxorbiggraphics, biggraphics,
  312. X    alpha50: boolean; 
  313. X    end; 
  314. X
  315. X  sysflag2[hex('FFFFFEDA')]: packed record    {extend to 8 digits SFB 4/26/85}
  316. X                             pad7to1    : 0..127;
  317. X                             prompresent: boolean;
  318. X                           end;
  319. X                           
  320. X  endsysvars : shortint;   {must be last thing
  321. X                            in SYSGLOBALS}
  322. X  
  323. X
  324. Xend.
  325. X
  326. END_OF_FILE
  327. if test 13046 -ne `wc -c <'HP/import/sysglobals.imp'`; then
  328.     echo shar: \"'HP/import/sysglobals.imp'\" unpacked with wrong size!
  329. fi
  330. # end of 'HP/import/sysglobals.imp'
  331. fi
  332. if test -f 'src/COPYING' -a "${1}" != "-c" ; then 
  333.   echo shar: Will not clobber existing file \"'src/COPYING'\"
  334. else
  335. echo shar: Extracting \"'src/COPYING'\" \(12488 characters\)
  336. sed "s/^X//" >'src/COPYING' <<'END_OF_FILE'
  337. X
  338. X            GNU GENERAL PUBLIC LICENSE
  339. X             Version 1, February 1989
  340. X
  341. X Copyright (C) 1989 Free Software Foundation, Inc.
  342. X                    675 Mass Ave, Cambridge, MA 02139, USA
  343. X Everyone is permitted to copy and distribute verbatim copies
  344. X of this license document, but changing it is not allowed.
  345. X
  346. X                Preamble
  347. X
  348. X  The license agreements of most software companies try to keep users
  349. Xat the mercy of those companies.  By contrast, our General Public
  350. XLicense is intended to guarantee your freedom to share and change free
  351. Xsoftware--to make sure the software is free for all its users.  The
  352. XGeneral Public License applies to the Free Software Foundation's
  353. Xsoftware and to any other program whose authors commit to using it.
  354. XYou can use it for your programs, too.
  355. X
  356. X  When we speak of free software, we are referring to freedom, not
  357. Xprice.  Specifically, the General Public License is designed to make
  358. Xsure that you have the freedom to give away or sell copies of free
  359. Xsoftware, that you receive source code or can get it if you want it,
  360. Xthat you can change the software or use pieces of it in new free
  361. Xprograms; and that you know you can do these things.
  362. X
  363. X  To protect your rights, we need to make restrictions that forbid
  364. Xanyone to deny you these rights or to ask you to surrender the rights.
  365. XThese restrictions translate to certain responsibilities for you if you
  366. Xdistribute copies of the software, or if you modify it.
  367. X
  368. X  For example, if you distribute copies of a such a program, whether
  369. Xgratis or for a fee, you must give the recipients all the rights that
  370. Xyou have.  You must make sure that they, too, receive or can get the
  371. Xsource code.  And you must tell them their rights.
  372. X
  373. X  We protect your rights with two steps: (1) copyright the software, and
  374. X(2) offer you this license which gives you legal permission to copy,
  375. Xdistribute and/or modify the software.
  376. X
  377. X  Also, for each author's protection and ours, we want to make certain
  378. Xthat everyone understands that there is no warranty for this free
  379. Xsoftware.  If the software is modified by someone else and passed on, we
  380. Xwant its recipients to know that what they have is not the original, so
  381. Xthat any problems introduced by others will not reflect on the original
  382. Xauthors' reputations.
  383. X
  384. X  The precise terms and conditions for copying, distribution and
  385. Xmodification follow.
  386. X
  387. X            GNU GENERAL PUBLIC LICENSE
  388. X   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  389. X
  390. X  0. This License Agreement applies to any program or other work which
  391. Xcontains a notice placed by the copyright holder saying it may be
  392. Xdistributed under the terms of this General Public License.  The
  393. X"Program", below, refers to any such program or work, and a "work based
  394. Xon the Program" means either the Program or any work containing the
  395. XProgram or a portion of it, either verbatim or with modifications.  Each
  396. Xlicensee is addressed as "you".
  397. X
  398. X  1. You may copy and distribute verbatim copies of the Program's source
  399. Xcode as you receive it, in any medium, provided that you conspicuously and
  400. Xappropriately publish on each copy an appropriate copyright notice and
  401. Xdisclaimer of warranty; keep intact all the notices that refer to this
  402. XGeneral Public License and to the absence of any warranty; and give any
  403. Xother recipients of the Program a copy of this General Public License
  404. Xalong with the Program.  You may charge a fee for the physical act of
  405. Xtransferring a copy.
  406. X
  407. X  2. You may modify your copy or copies of the Program or any portion of
  408. Xit, and copy and distribute such modifications under the terms of Paragraph
  409. X1 above, provided that you also do the following:
  410. X
  411. X    a) cause the modified files to carry prominent notices stating that
  412. X    you changed the files and the date of any change; and
  413. X
  414. X    b) cause the whole of any work that you distribute or publish, that
  415. X    in whole or in part contains the Program or any part thereof, either
  416. X    with or without modifications, to be licensed at no charge to all
  417. X    third parties under the terms of this General Public License (except
  418. X    that you may choose to grant warranty protection to some or all
  419. X    third parties, at your option).
  420. X
  421. X    c) If the modified program normally reads commands interactively when
  422. X    run, you must cause it, when started running for such interactive use
  423. X    in the simplest and most usual way, to print or display an
  424. X    announcement including an appropriate copyright notice and a notice
  425. X    that there is no warranty (or else, saying that you provide a
  426. X    warranty) and that users may redistribute the program under these
  427. X    conditions, and telling the user how to view a copy of this General
  428. X    Public License.
  429. X
  430. X    d) You may charge a fee for the physical act of transferring a
  431. X    copy, and you may at your option offer warranty protection in
  432. X    exchange for a fee.
  433. X
  434. XMere aggregation of another independent work with the Program (or its
  435. Xderivative) on a volume of a storage or distribution medium does not bring
  436. Xthe other work under the scope of these terms.
  437. X
  438. X  3. You may copy and distribute the Program (or a portion or derivative of
  439. Xit, under Paragraph 2) in object code or executable form under the terms of
  440. XParagraphs 1 and 2 above provided that you also do one of the following:
  441. X
  442. X    a) accompany it with the complete corresponding machine-readable
  443. X    source code, which must be distributed under the terms of
  444. X    Paragraphs 1 and 2 above; or,
  445. X
  446. X    b) accompany it with a written offer, valid for at least three
  447. X    years, to give any third party free (except for a nominal charge
  448. X    for the cost of distribution) a complete machine-readable copy of the
  449. X    corresponding source code, to be distributed under the terms of
  450. X    Paragraphs 1 and 2 above; or,
  451. X
  452. X    c) accompany it with the information you received as to where the
  453. X    corresponding source code may be obtained.  (This alternative is
  454. X    allowed only for noncommercial distribution and only if you
  455. X    received the program in object code or executable form alone.)
  456. X
  457. XSource code for a work means the preferred form of the work for making
  458. Xmodifications to it.  For an executable file, complete source code means
  459. Xall the source code for all modules it contains; but, as a special
  460. Xexception, it need not include source code for modules which are standard
  461. Xlibraries that accompany the operating system on which the executable
  462. Xfile runs, or for standard header files or definitions files that
  463. Xaccompany that operating system.
  464. X
  465. X  4. You may not copy, modify, sublicense, distribute or transfer the
  466. XProgram except as expressly provided under this General Public License.
  467. XAny attempt otherwise to copy, modify, sublicense, distribute or transfer
  468. Xthe Program is void, and will automatically terminate your rights to use
  469. Xthe Program under this License.  However, parties who have received
  470. Xcopies, or rights to use copies, from you under this General Public
  471. XLicense will not have their licenses terminated so long as such parties
  472. Xremain in full compliance.
  473. X
  474. X  5. By copying, distributing or modifying the Program (or any work based
  475. Xon the Program) you indicate your acceptance of this license to do so,
  476. Xand all its terms and conditions.
  477. X
  478. X  6. Each time you redistribute the Program (or any work based on the
  479. XProgram), the recipient automatically receives a license from the original
  480. Xlicensor to copy, distribute or modify the Program subject to these
  481. Xterms and conditions.  You may not impose any further restrictions on the
  482. Xrecipients' exercise of the rights granted herein.
  483. X
  484. X  7. The Free Software Foundation may publish revised and/or new versions
  485. Xof the General Public License from time to time.  Such new versions will
  486. Xbe similar in spirit to the present version, but may differ in detail to
  487. Xaddress new problems or concerns.
  488. X
  489. XEach version is given a distinguishing version number.  If the Program
  490. Xspecifies a version number of the license which applies to it and "any
  491. Xlater version", you have the option of following the terms and conditions
  492. Xeither of that version or of any later version published by the Free
  493. XSoftware Foundation.  If the Program does not specify a version number of
  494. Xthe license, you may choose any version ever published by the Free Software
  495. XFoundation.
  496. X
  497. X  8. If you wish to incorporate parts of the Program into other free
  498. Xprograms whose distribution conditions are different, write to the author
  499. Xto ask for permission.  For software which is copyrighted by the Free
  500. XSoftware Foundation, write to the Free Software Foundation; we sometimes
  501. Xmake exceptions for this.  Our decision will be guided by the two goals
  502. Xof preserving the free status of all derivatives of our free software and
  503. Xof promoting the sharing and reuse of software generally.
  504. X
  505. X                NO WARRANTY
  506. X
  507. X  9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
  508. XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
  509. XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
  510. XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
  511. XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  512. XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
  513. XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
  514. XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
  515. XREPAIR OR CORRECTION.
  516. X
  517. X  10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  518. XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
  519. XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
  520. XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
  521. XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
  522. XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
  523. XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
  524. XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
  525. XPOSSIBILITY OF SUCH DAMAGES.
  526. X
  527. X             END OF TERMS AND CONDITIONS
  528. X
  529. X    Appendix: How to Apply These Terms to Your New Programs
  530. X
  531. X  If you develop a new program, and you want it to be of the greatest
  532. Xpossible use to humanity, the best way to achieve this is to make it
  533. Xfree software which everyone can redistribute and change under these
  534. Xterms.
  535. X
  536. X  To do so, attach the following notices to the program.  It is safest to
  537. Xattach them to the start of each source file to most effectively convey
  538. Xthe exclusion of warranty; and each file should have at least the
  539. X"copyright" line and a pointer to where the full notice is found.
  540. X
  541. X    <one line to give the program's name and a brief idea of what it does.>
  542. X    Copyright (C) 19yy  <name of author>
  543. X
  544. X    This program is free software; you can redistribute it and/or modify
  545. X    it under the terms of the GNU General Public License as published by
  546. X    the Free Software Foundation; either version 1, or (at your option)
  547. X    any later version.
  548. X
  549. X    This program is distributed in the hope that it will be useful,
  550. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  551. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  552. X    GNU General Public License for more details.
  553. X
  554. X    You should have received a copy of the GNU General Public License
  555. X    along with this program; if not, write to the Free Software
  556. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  557. X
  558. XAlso add information on how to contact you by electronic and paper mail.
  559. X
  560. XIf the program is interactive, make it output a short notice like this
  561. Xwhen it starts in an interactive mode:
  562. X
  563. X    Gnomovision version 69, Copyright (C) 19xx name of author
  564. X    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
  565. X    This is free software, and you are welcome to redistribute it
  566. X    under certain conditions; type `show c' for details.
  567. X
  568. XThe hypothetical commands `show w' and `show c' should show the
  569. Xappropriate parts of the General Public License.  Of course, the
  570. Xcommands you use may be called something other than `show w' and `show
  571. Xc'; they could even be mouse-clicks or menu items--whatever suits your
  572. Xprogram.
  573. X
  574. XYou should also get your employer (if you work as a programmer) or your
  575. Xschool, if any, to sign a "copyright disclaimer" for the program, if
  576. Xnecessary.  Here a sample; alter the names:
  577. X
  578. X  Yoyodyne, Inc., hereby disclaims all copyright interest in the
  579. X  program `Gnomovision' (a program to direct compilers to make passes
  580. X  at assemblers) written by James Hacker.
  581. X
  582. X  <signature of Ty Coon>, 1 April 1989
  583. X  Ty Coon, President of Vice
  584. X
  585. XThat's all there is to it!
  586. END_OF_FILE
  587. if test 12488 -ne `wc -c <'src/COPYING'`; then
  588.     echo shar: \"'src/COPYING'\" unpacked with wrong size!
  589. fi
  590. # end of 'src/COPYING'
  591. fi
  592. if test -f 'src/stuff.c' -a "${1}" != "-c" ; then 
  593.   echo shar: Will not clobber existing file \"'src/stuff.c'\"
  594. else
  595. echo shar: Extracting \"'src/stuff.c'\" \(13512 characters\)
  596. sed "s/^X//" >'src/stuff.c' <<'END_OF_FILE'
  597. X/* "p2c", a Pascal to C translator.
  598. X   Copyright (C) 1989 David Gillespie.
  599. X   Author's address: daveg@csvax.caltech.edu; 256-80 Caltech/Pasadena CA 91125.
  600. X
  601. XThis program is free software; you can redistribute it and/or modify
  602. Xit under the terms of the GNU General Public License as published by
  603. Xthe Free Software Foundation (any version).
  604. X
  605. XThis program is distributed in the hope that it will be useful,
  606. Xbut WITHOUT ANY WARRANTY; without even the implied warranty of
  607. XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  608. XGNU General Public License for more details.
  609. X
  610. XYou should have received a copy of the GNU General Public License
  611. Xalong with this program; see the file COPYING.  If not, write to
  612. Xthe Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
  613. X
  614. X
  615. X
  616. X#define PROTO_STUFF_C
  617. X#include "trans.h"
  618. X
  619. X
  620. X
  621. X
  622. X
  623. X
  624. X/* Called regularly, for debugging purposes */
  625. X
  626. Xvoid debughook()
  627. X{
  628. X#if 0
  629. X    Symbol *sp;
  630. X    Meaning *mp;
  631. X    static int flag = 0;
  632. X
  633. X    sp = findsymbol_opt("DEFSTIPPLES");
  634. X    if (sp) {
  635. X    mp = sp->mbase;
  636. X    if (mp) {
  637. X        flag = 1;
  638. X        if (mp->sym != sp || mp->snext)
  639. X        intwarning("debughook", "Inconsistent!");
  640. X    } else
  641. X        if (flag)
  642. X        intwarning("debughook", "Missing!");
  643. X    }
  644. X#endif
  645. X}
  646. X
  647. X
  648. X
  649. X
  650. X
  651. X
  652. X/* The "Strlist" data type, like in NEWASM */
  653. X
  654. X
  655. X/* Add a string to end of strlist */
  656. X
  657. XStrlist *strlist_append(base, s)
  658. Xregister Strlist **base;
  659. Xregister char *s;
  660. X{
  661. X    register Strlist *p;
  662. X
  663. X    while (*base)
  664. X        base = &(*base)->next;
  665. X    *base = p = ALLOCV(sizeof(Strlist) + strlen(s), Strlist, strlists);
  666. X    p->next = NULL;
  667. X    p->value = 0;
  668. X    strcpy(p->s, s);
  669. X    return p;
  670. X}
  671. X
  672. X
  673. X
  674. X/* Insert a string at front of strlist */
  675. X
  676. XStrlist *strlist_insert(base, s)
  677. Xregister Strlist **base;
  678. Xregister char *s;
  679. X{
  680. X    register Strlist *p;
  681. X
  682. X    p = ALLOCV(sizeof(Strlist) + strlen(s), Strlist, strlists);
  683. X    p->next = *base;
  684. X    *base = p;
  685. X    p->value = 0;
  686. X    strcpy(p->s, s);
  687. X    return p;
  688. X}
  689. X
  690. X
  691. X
  692. X/* Add a string to a sorted strlist */
  693. X
  694. XStrlist *strlist_add(base, s)
  695. Xregister Strlist **base;
  696. Xregister char *s;
  697. X{
  698. X    register Strlist *p;
  699. X
  700. X    while ((p = *base) && strcmp(p->s, s) < 0)
  701. X        base = &p->next;
  702. X    if (!p || strcmp(p->s, s)) {
  703. X        p = ALLOCV(sizeof(Strlist) + strlen(s), Strlist, strlists);
  704. X        p->next = *base;
  705. X        *base = p;
  706. X        strcpy(p->s, s);
  707. X    }
  708. X    p->value = 0;
  709. X    return p;
  710. X}
  711. X
  712. X
  713. X
  714. X/* Append two strlists together */
  715. X
  716. Xvoid strlist_mix(base, sl)
  717. Xregister Strlist **base;
  718. XStrlist *sl;
  719. X{
  720. X    if (sl) {
  721. X    while (*base)
  722. X        base = &(*base)->next;
  723. X    *base = sl;
  724. X    }
  725. X}
  726. X
  727. X
  728. X
  729. X/* Remove the first element of a strlist */
  730. X
  731. Xvoid strlist_eat(base)
  732. Xregister Strlist **base;
  733. X{
  734. X    register Strlist *p;
  735. X
  736. X    if ((p = *base) != NULL) {
  737. X        *base = p->next;
  738. X        FREE(p);
  739. X    }
  740. X}
  741. X
  742. X
  743. X
  744. X/* Remove all elements of a strlist */
  745. X
  746. Xvoid strlist_empty(base)
  747. Xregister Strlist **base;
  748. X{
  749. X    register Strlist *p;
  750. X
  751. X    if (!base) {
  752. X    intwarning("strlist_empty", "NULL base pointer [312]");
  753. X    return;
  754. X    }
  755. X    while ((p = *base) != NULL) {
  756. X        *base = p->next;
  757. X        FREE(p);
  758. X    }
  759. X}
  760. X
  761. X
  762. X
  763. X/* Remove first occurrence of a given string */
  764. X
  765. Xvoid strlist_remove(base, s)
  766. Xregister Strlist **base;
  767. Xregister char *s;
  768. X{
  769. X    register Strlist *p;
  770. X
  771. X    while ((p = *base) != NULL) {
  772. X    if (!strcmp(p->s, s)) {
  773. X        *base = p->next;
  774. X        FREE(p);
  775. X    } else
  776. X        base = &p->next;
  777. X    }
  778. X}
  779. X
  780. X
  781. X
  782. X/* Remove a given entry from a strlist */
  783. X
  784. Xvoid strlist_delete(base, sl)
  785. Xregister Strlist **base, *sl;
  786. X{
  787. X    register Strlist *p;
  788. X
  789. X    while ((p = *base) && p != sl)
  790. X        base = &p->next;
  791. X    if (p) {
  792. X        *base = p->next;
  793. X        FREE(p);
  794. X    }
  795. X}
  796. X
  797. X
  798. X
  799. X/* Find the first occurrence of a string */
  800. X
  801. XStrlist *strlist_find(base, s)
  802. Xregister Strlist *base;
  803. Xregister char *s;
  804. X{
  805. X    if (!s)
  806. X    return NULL;
  807. X    while (base && strcmp(base->s, s))
  808. X        base = base->next;
  809. X    return base;
  810. X}
  811. X
  812. X
  813. X
  814. X/* Case-insensitive version of strlist_find */
  815. X
  816. XStrlist *strlist_cifind(base, s)
  817. Xregister Strlist *base;
  818. Xregister char *s;
  819. X{
  820. X    if (!s)
  821. X    return NULL;
  822. X    while (base && strcicmp(base->s, s))
  823. X        base = base->next;
  824. X    return base;
  825. X}
  826. X
  827. X
  828. X
  829. X
  830. X
  831. X
  832. X/* String comparisons */
  833. X
  834. X
  835. Xint strcincmp(s1, s2, n)
  836. Xregister char *s1, *s2;
  837. Xregister int n;
  838. X{
  839. X    register unsigned char ch1, ch2;
  840. X
  841. X    while (--n >= 0) {
  842. X        if (!(ch1 = *s1++))
  843. X            return (*s2) ? -1 : 0;
  844. X        if (!(ch2 = *s2++))
  845. X            return 1;
  846. X        if (islower(ch1))
  847. X            ch1 = _toupper(ch1);
  848. X        if (islower(ch2))
  849. X            ch2 = _toupper(ch2);
  850. X        if (ch1 != ch2)
  851. X            return ch1 - ch2;
  852. X    }
  853. X    return 0;
  854. X}
  855. X
  856. X
  857. X
  858. Xint strcicmp(s1, s2)
  859. Xregister char *s1, *s2;
  860. X{
  861. X    register unsigned char ch1, ch2;
  862. X
  863. X    for (;;) {
  864. X        if (!(ch1 = *s1++))
  865. X            return (*s2) ? -1 : 0;
  866. X        if (!(ch2 = *s2++))
  867. X            return 1;
  868. X        if (islower(ch1))
  869. X            ch1 = _toupper(ch1);
  870. X        if (islower(ch2))
  871. X            ch2 = _toupper(ch2);
  872. X        if (ch1 != ch2)
  873. X            return ch1 - ch2;
  874. X    }
  875. X}
  876. X
  877. X
  878. X
  879. X
  880. X
  881. X
  882. X/* File name munching */
  883. X
  884. X
  885. Xvoid fixfname(fn, ext)
  886. Xchar *fn, *ext;
  887. X{
  888. X    char *cp, *cp2;
  889. X
  890. X    if (!ext)
  891. X        return;
  892. X    cp = my_strrchr(fn, '.');
  893. X    cp2 = my_strrchr(fn, '/');
  894. X    if (cp && (!cp2 || cp > cp2)) {
  895. X        if (!cp[1])     /* remove trailing '.' */
  896. X            *cp = 0;
  897. X    } else {
  898. X        strcat(fn, ".");
  899. X        strcat(fn, ext);
  900. X    }
  901. X}
  902. X
  903. X
  904. X
  905. Xvoid removesuffix(fn)
  906. Xchar *fn;
  907. X{
  908. X    char *cp, *cp2;
  909. X
  910. X    cp = my_strrchr(fn, '.');
  911. X    if (!cp)
  912. X        return;
  913. X#if defined(unix) || defined(__unix)
  914. X    cp2 = my_strrchr(fn, '/');
  915. X    if (cp2 && cp < cp2)
  916. X        return;
  917. X#endif
  918. X    *cp = 0;
  919. X}
  920. X
  921. X
  922. X
  923. X
  924. X
  925. X
  926. X/* Dynamically-allocated strings */
  927. X
  928. X
  929. Xchar *stralloc(s)
  930. Xchar *s;
  931. X{
  932. X    register char *buf = ALLOC(strlen(s) + 1, char, strings);
  933. X    strcpy(buf, s);
  934. X    return buf;
  935. X}
  936. X
  937. X
  938. X
  939. Xvoid strchange(v, s)
  940. Xchar **v, *s;
  941. X{
  942. X    s = stralloc(s);   /* do this first in case **v and *s overlap */
  943. X    FREE(*v);
  944. X    *v = s;
  945. X}
  946. X
  947. X
  948. X
  949. X
  950. X
  951. X/* Handy string formatting */
  952. X
  953. X#define NUMBUF 8
  954. Xstatic char *(formatbuf[NUMBUF]);
  955. Xstatic int nextformat = -1;
  956. X
  957. X#define getformat()  ((nextformat=(nextformat+1)%NUMBUF), formatbuf[nextformat])
  958. X
  959. X
  960. X#define FF_UCASE   0x1
  961. X#define FF_LCASE   0x2
  962. X#define FF_REMSUFF 0x4
  963. X#define FF_UNDER   0x8     /* Thanks to William Bader for suggesting these */
  964. X#define FF_PRESERVE 0x10
  965. X#define FF_REMSLASH 0x20
  966. X#define FF_REMUNDER 0x40
  967. X
  968. XStatic void cvcase(buf, flags)
  969. Xchar *buf;
  970. Xint flags;
  971. X{
  972. X    char *cp, *cp2;
  973. X    int ulflag, i;
  974. X
  975. X    if (flags & FF_PRESERVE) {
  976. X        ulflag = 0;
  977. X    for (cp = buf; *cp; cp++) {
  978. X        if (isupper(*cp))
  979. X        ulflag |= 1;
  980. X        else if (islower(*cp))
  981. X        ulflag |= 2;
  982. X    }
  983. X    if (ulflag == 3)
  984. X        flags &= ~(FF_UCASE | FF_LCASE);
  985. X    }
  986. X    if ((flags & FF_UNDER) && *buf) {
  987. X        for (cp = buf + 1; *cp; cp++) {
  988. X            if (isupper(*cp) && islower(cp[-1])) {
  989. X        for (i = strlen(cp); i >= 0; i--)
  990. X            cp[i+1] = cp[i];
  991. X        *cp++ = '_';
  992. X        }
  993. X    }
  994. X    }
  995. X    if (flags & FF_UCASE) {
  996. X    if (flags & FF_LCASE) {
  997. X        for (cp = buf; *cp; cp++) {
  998. X        if (cp == buf || !isalpha(cp[-1]))
  999. X            *cp = toupper(*cp);
  1000. X        else
  1001. X            *cp = tolower(*cp);
  1002. X        }
  1003. X    } else
  1004. X        upc(buf);
  1005. X    } else if (flags & FF_LCASE)
  1006. X    lwc(buf);
  1007. X    if (flags & FF_REMUNDER) {
  1008. X    for (cp = cp2 = buf; *cp; cp++) {
  1009. X        if (isalnum(*cp))
  1010. X        *cp2++ = *cp;
  1011. X    }
  1012. X    if (cp2 > buf)
  1013. X        *cp2 = 0;
  1014. X    }
  1015. X}
  1016. X
  1017. X
  1018. Xchar *format_gen(fmt, i1, i2, dbl, s1, s2, s3)
  1019. Xchar *fmt;
  1020. Xlong i1, i2;
  1021. Xdouble dbl;
  1022. Xchar *s1, *s2, *s3;
  1023. X{
  1024. X    char *buf = getformat();
  1025. X    char *dst = buf, *src = fmt, *cp, *cp2, *saves2 = s2;
  1026. X    int wid, prec;
  1027. X    int flags;
  1028. X    char fmtbuf[50], *fp;
  1029. X
  1030. X    debughook();
  1031. X    while (*src) {
  1032. X    if (*src != '%') {
  1033. X        *dst++ = *src++;
  1034. X        continue;
  1035. X    }
  1036. X    src++;
  1037. X    wid = -1;
  1038. X    prec = -1;
  1039. X    flags = 0;
  1040. X    fp = fmtbuf;
  1041. X    *fp++ = '%';
  1042. X    for (;;) {
  1043. X        if (*src == '-' || *src == '+' || *src == ' ' || *src == '#') {
  1044. X        *fp++ = *src;
  1045. X        } else if (*src == '^') {
  1046. X        flags |= FF_UCASE;
  1047. X        } else if (*src == '_') {
  1048. X        flags |= FF_LCASE;
  1049. X        } else if (*src == 'R') {
  1050. X        flags |= FF_REMSUFF;
  1051. X        } else if (*src == '~') {
  1052. X        flags |= FF_UNDER;
  1053. X        } else if (*src == '!') {
  1054. X        flags |= FF_REMUNDER;
  1055. X        } else if (*src == '?') {
  1056. X        flags |= FF_PRESERVE;
  1057. X        } else if (*src == '/') {
  1058. X        flags |= FF_REMSLASH;
  1059. X        } else
  1060. X        break;
  1061. X        src++;
  1062. X    }
  1063. X    if (isdigit(*src)) {
  1064. X        wid = 0;
  1065. X        while (isdigit(*src))
  1066. X        wid = wid*10 + (*fp++ = *src++) - '0';
  1067. X    } else if (*src == '*') {
  1068. X        src++;
  1069. X        wid = i1;
  1070. X        sprintf(fp, "%d", wid);
  1071. X        fp = fp + strlen(fp);
  1072. X        if (wid < 0)
  1073. X        wid = -wid;
  1074. X        i1 = i2;
  1075. X    }
  1076. X    if (*src == '.') {
  1077. X        if (*++src == '*') {
  1078. X        prec = i1;
  1079. X        i1 = i2;
  1080. X        src++;
  1081. X        } else {
  1082. X        prec = 0;
  1083. X        while (isdigit(*src))
  1084. X            prec = prec*10 + (*src++) - '0';
  1085. X        }
  1086. X        sprintf(fp, ".%d", prec);
  1087. X        fp = fp + strlen(fp);
  1088. X    }
  1089. X    if (*src == 'l' || *src == 'h')
  1090. X        src++;
  1091. X    switch (*src) {
  1092. X
  1093. X      case '%':
  1094. X        *dst++ = '%';
  1095. X        break;
  1096. X
  1097. X      case 'H':
  1098. X        strcpy(dst, p2c_home);
  1099. X        dst = dst + strlen(dst);
  1100. X        break;
  1101. X
  1102. X      case 'd':
  1103. X      case 'i':
  1104. X      case 'o':
  1105. X      case 'u':
  1106. X      case 'x':
  1107. X      case 'X':
  1108. X        *fp++ = 'l';
  1109. X        *fp++ = *src;
  1110. X        *fp = 0;
  1111. X        sprintf(dst, fmtbuf, i1);
  1112. X        i1 = i2;
  1113. X        cvcase(dst, flags);
  1114. X        dst = dst + strlen(dst);
  1115. X        break;
  1116. X
  1117. X      case 'c':
  1118. X        *fp++ = *src;
  1119. X        *fp = 0;
  1120. X        sprintf(dst, fmtbuf, (int)i1);
  1121. X        i1 = i2;
  1122. X        cvcase(dst, flags);
  1123. X        dst = dst + strlen(dst);
  1124. X        break;
  1125. X
  1126. X      case 'e':
  1127. X      case 'E':
  1128. X      case 'f':
  1129. X      case 'g':
  1130. X      case 'G':
  1131. X        *fp++ = *src;
  1132. X        *fp++ = 0;
  1133. X        sprintf(dst, fmtbuf, dbl);
  1134. X        cvcase(dst, flags);
  1135. X        dst = dst + strlen(dst);
  1136. X        break;
  1137. X
  1138. X      case 's':
  1139. X      case 'S':
  1140. X        *fp++ = 's';
  1141. X        *fp = 0;
  1142. X        if (*src == 'S' && saves2) {
  1143. X        cp = saves2;
  1144. X        } else {
  1145. X        cp = s1;
  1146. X        s1 = s2;
  1147. X        s2 = s3;
  1148. X        }
  1149. X        if (flags & FF_REMSUFF) {
  1150. X        cp = format_s("%s", cp);
  1151. X        removesuffix(cp);
  1152. X        }
  1153. X        if (flags & FF_REMSLASH) {
  1154. X        cp2 = cp + strlen(cp);
  1155. X        while (cp2 >= cp &&
  1156. X               *cp2 != '/' && *cp2 != '\\' &&
  1157. X               *cp2 != ']' && *cp2 != ':')
  1158. X            cp2--;
  1159. X        if (cp2[1])
  1160. X            cp = cp2 + 1;
  1161. X        }
  1162. X        sprintf(dst, fmtbuf, cp);
  1163. X        cvcase(dst, flags);
  1164. X        dst = dst + strlen(dst);
  1165. X        break;
  1166. X
  1167. X    }
  1168. X    src++;
  1169. X    }
  1170. X    *dst = 0;
  1171. X    return buf;
  1172. X}
  1173. X
  1174. X
  1175. X
  1176. X
  1177. Xchar *format_none(fmt)
  1178. Xchar *fmt;
  1179. X{
  1180. X    return format_gen(fmt, 0L, 0L, 0.0, NULL, NULL, NULL);
  1181. X}
  1182. X
  1183. X
  1184. Xchar *format_d(fmt, a1)
  1185. Xchar *fmt;
  1186. Xint a1;
  1187. X{
  1188. X    return format_gen(fmt, a1, 0L, (double)a1, NULL, NULL, NULL);
  1189. X}
  1190. X
  1191. X
  1192. Xchar *format_g(fmt, a1)
  1193. Xchar *fmt;
  1194. Xdouble a1;
  1195. X{
  1196. X    return format_gen(fmt, (long)a1, 0L, a1, NULL, NULL, NULL);
  1197. X}
  1198. X
  1199. X
  1200. Xchar *format_s(fmt, a1)
  1201. Xchar *fmt, *a1;
  1202. X{
  1203. X    return format_gen(fmt, 0L, 0L, 0.0, a1, NULL, NULL);
  1204. X}
  1205. X
  1206. X
  1207. Xchar *format_ss(fmt, a1, a2)
  1208. Xchar *fmt, *a1, *a2;
  1209. X{
  1210. X    return format_gen(fmt, 0L, 0L, 0.0, a1, a2, NULL);
  1211. X}
  1212. X
  1213. X
  1214. Xchar *format_sd(fmt, a1, a2)
  1215. Xchar *fmt, *a1;
  1216. Xint a2;
  1217. X{
  1218. X    return format_gen(fmt, a2, 0L, (double)a2, a1, NULL, NULL);
  1219. X}
  1220. X
  1221. X
  1222. Xchar *format_ds(fmt, a1, a2)
  1223. Xchar *fmt, *a2;
  1224. Xlong a1;
  1225. X{
  1226. X    return format_gen(fmt, a1, 0L, (double)a1, a2, NULL, NULL);
  1227. X}
  1228. X
  1229. X
  1230. Xchar *format_dd(fmt, a1, a2)
  1231. Xchar *fmt;
  1232. Xlong a1, a2;
  1233. X{
  1234. X    return format_gen(fmt, a1, a2, (double)a1, NULL, NULL, NULL);
  1235. X}
  1236. X
  1237. X
  1238. Xchar *format_sss(fmt, a1, a2, a3)
  1239. Xchar *fmt, *a1, *a2, *a3;
  1240. X{
  1241. X    return format_gen(fmt, 0L, 0L, 0.0, a1, a2, a3);
  1242. X}
  1243. X
  1244. X
  1245. Xchar *format_ssd(fmt, a1, a2, a3)
  1246. Xchar *fmt, *a1, *a2;
  1247. Xlong a3;
  1248. X{
  1249. X    return format_gen(fmt, a3, 0L, (double)a3, a1, a2, NULL);
  1250. X}
  1251. X
  1252. X
  1253. Xchar *format_sds(fmt, a1, a2, a3)
  1254. Xchar *fmt, *a1, *a3;
  1255. Xlong a2;
  1256. X{
  1257. X    return format_gen(fmt, a2, 0L, (double)a2, a1, a3, NULL);
  1258. X}
  1259. X
  1260. X
  1261. X
  1262. X
  1263. X/* String conversions */
  1264. X
  1265. Xint my_toupper(c)
  1266. Xint c;
  1267. X{
  1268. X    if (islower(c))
  1269. X    return _toupper(c);
  1270. X    else
  1271. X    return c;
  1272. X}
  1273. X
  1274. X
  1275. Xint my_tolower(c)
  1276. Xint c;
  1277. X{
  1278. X    if (isupper(c))
  1279. X    return _tolower(c);
  1280. X    else
  1281. X    return c;
  1282. X}
  1283. X
  1284. X
  1285. Xvoid upc(s)
  1286. Xregister char *s;
  1287. X{
  1288. X    for (; *s; s++)
  1289. X        *s = toupper(*s);
  1290. X}
  1291. X
  1292. X
  1293. Xvoid lwc(s)
  1294. Xregister char *s;
  1295. X{
  1296. X    for (; *s; s++)
  1297. X        *s = tolower(*s);
  1298. X}
  1299. X
  1300. X
  1301. Xchar *strupper(s)
  1302. Xregister char *s;
  1303. X{
  1304. X    char *dest = getformat();
  1305. X    register char *s2 = dest;
  1306. X    while (*s)
  1307. X        *s2++ = toupper(*s++);
  1308. X    *s2 = 0;
  1309. X    return dest;
  1310. X}
  1311. X
  1312. X
  1313. Xchar *strlower(s)
  1314. Xregister char *s;
  1315. X{
  1316. X    char *dest = getformat();
  1317. X    register char *s2 = dest;
  1318. X    while (*s)
  1319. X        *s2++ = tolower(*s++);
  1320. X    *s2 = 0;
  1321. X    return dest;
  1322. X}
  1323. X
  1324. X
  1325. X
  1326. Xchar *my_strchr(cp, c)
  1327. Xregister char *cp;
  1328. Xint c;
  1329. X{
  1330. X    while (*cp && *cp != c)
  1331. X    cp++;
  1332. X    if (*cp)
  1333. X    return cp;
  1334. X    else
  1335. X    return NULL;
  1336. X}
  1337. X
  1338. X
  1339. Xchar *my_strrchr(cp, c)
  1340. Xregister char *cp;
  1341. Xint c;
  1342. X{
  1343. X    register char *cp2 = NULL;
  1344. X    while (*cp) {
  1345. X    if (*cp == c)
  1346. X        cp2 = cp;
  1347. X    cp++;
  1348. X    }
  1349. X    return cp2;
  1350. X}
  1351. X
  1352. X
  1353. Xchar *my_strtok(cp, delim)
  1354. Xchar *cp, *delim;
  1355. X{
  1356. X    static char *ptr;
  1357. X
  1358. X    if (cp)
  1359. X    ptr = cp;
  1360. X    while (*ptr && my_strchr(delim, *ptr))
  1361. X    ptr++;
  1362. X    if (!*ptr)
  1363. X    return NULL;
  1364. X    cp = ptr;
  1365. X    while (*ptr && !my_strchr(delim, *ptr))
  1366. X    ptr++;
  1367. X    *ptr++ = 0;
  1368. X    return cp;
  1369. X}
  1370. X
  1371. X
  1372. X
  1373. Xlong my_strtol(buf, ret, base)
  1374. Xchar *buf, **ret;
  1375. Xint base;
  1376. X{
  1377. X    unsigned long val = 0;
  1378. X    int dig, sign = 1;
  1379. X
  1380. X    while (isspace(*buf))
  1381. X    buf++;
  1382. X    if (*buf == '+')
  1383. X    buf++;
  1384. X    else if (*buf == '-') {
  1385. X    sign = -1;
  1386. X    buf++;
  1387. X    }
  1388. X    if (*buf == '0') {
  1389. X    if ((buf[1] == 'x' || buf[1] == 'X') &&
  1390. X        (base == 0 || base == 16)) {
  1391. X        buf++;
  1392. X        base = 16;
  1393. X    } else if (base == 0)
  1394. X        base = 8;
  1395. X    buf++;
  1396. X    }
  1397. X    for (;;) {
  1398. X    if (isdigit(*buf))
  1399. X        dig = *buf - '0';
  1400. X    else if (*buf >= 'a')
  1401. X        dig = *buf - 'a' + 10;
  1402. X    else if (*buf >= 'A')
  1403. X        dig = *buf - 'A' + 10;
  1404. X    else
  1405. X        break;
  1406. X    if (dig >= base)
  1407. X        break;
  1408. X    val = val * base + dig;
  1409. X    buf++;
  1410. X    }
  1411. X    if (ret)
  1412. X    *ret = buf;
  1413. X    if (sign > 0)
  1414. X    return val;
  1415. X    else
  1416. X    return -val;
  1417. X}
  1418. X
  1419. X
  1420. X
  1421. X
  1422. Xvoid init_stuff()
  1423. X{
  1424. X    int i;
  1425. X
  1426. X    for (i = 0; i < NUMBUF; i++)
  1427. X        formatbuf[i] = ALLOC(1000, char, misc);
  1428. X}
  1429. X
  1430. X
  1431. X
  1432. X
  1433. X/* End. */
  1434. X
  1435. X
  1436. END_OF_FILE
  1437. if test 13512 -ne `wc -c <'src/stuff.c'`; then
  1438.     echo shar: \"'src/stuff.c'\" unpacked with wrong size!
  1439. fi
  1440. # end of 'src/stuff.c'
  1441. fi
  1442. echo shar: End of archive 5 \(of 32\).
  1443. cp /dev/null ark5isdone
  1444. MISSING=""
  1445. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ; do
  1446.     if test ! -f ark${I}isdone ; then
  1447.     MISSING="${MISSING} ${I}"
  1448.     fi
  1449. done
  1450. if test "${MISSING}" = "" ; then
  1451.     echo You have unpacked all 32 archives.
  1452.     echo "Now see PACKNOTES and the README"
  1453.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1454. else
  1455.     echo You still need to unpack the following archives:
  1456.     echo "        " ${MISSING}
  1457. fi
  1458. ##  End of shell archive.
  1459. exit 0
  1460.