home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 446.lha / parseargs / README.PDS < prev    next >
Encoding:
Text File  |  1990-12-06  |  3.3 KB  |  68 lines

  1. Update to parseargs by Peter da Silva (peter@ficc.uu.net).
  2. (second update: more improvements to arg parsing, argChar type)
  3. (third update, return to original calling sequence, argList type)
  4. (fourth update: removed routines not relevant to parseargs, removed
  5.     tracing/interactive stuff. )
  6.  
  7. Parseargs is a really nifty set of routines, but it doesn't fit too
  8. well with standard UNIX semantics. In particular, you can get into a
  9. lot of trouble using it in a script if it drops into interactive mode
  10. on you. Also, it's not as useful as it could be for non-UNIX systems.
  11. To make it work better, I've made a couple of changes.
  12.  
  13. It compiled straight out of the box on System III once I'd provided
  14. bcopy, bcmp, and strtol. The strtol I've provided is almost totally
  15. untested, but hopefully you won't need to use it. It's only for folks with
  16. old UNIX systems.
  17.  
  18. First change was to disable the interactive prompting for arguments.
  19. I think that's inconsistent with usual UNIX semantics.
  20.  
  21. The second change was to allow for a trailing list of arguments. I
  22. originally implemented this by changing the calling sequence to parseargs.
  23. On reflection this would just produce incompatibilities, so I added a
  24. new flag, ARGLIST, and a new type, listStr. Later, other kinds of lists
  25. can presumably be added. A list handles a pointer to a list of objects:
  26.  
  27.     struct arglist *fred;
  28.  
  29. Operations are defined on arglists, L_NEXT(fred) produces the next element
  30. in fred. L_STRING(fred) produces the value of fred cast to "char *".
  31.  
  32. During evaluation the list is kept in LIFO order, and it's reversed just
  33. before returning to parseargs. This simplifies the coding of the list
  34. routines, but still lets you step through the list in a reasonable order.
  35.  
  36. The final change is the addition of a 'argChar' type. This parses character
  37. arguments (such as the '-T' option to 'awk'), accepting single characters,
  38. '\nnn' octal escapes, and '^X' for control characters.
  39.  
  40. Parseargs itself no longer uses ckalloc, traceset, funclist, and so on.
  41. these routines are pretty cool, but when you're grafting parseargs onto
  42. an existing program they just get in the way. Also, it's possible to make
  43. parseargs fail in a cleaner fashion by handling out-of-memory cases myself.
  44. Certainly there's not going to be any loose memory lying around to be
  45. collected when parseargs starts up!
  46.  
  47. Also, the error messages have been made a bit more descriptive. Instead
  48. of saying "stest: value required for -c flag", it prints "stest: RepCount
  49. required for -c flag". The ad_prompt element should relly be a descriptive
  50. word that can be used in a sentence... or for non_UNIX systems a multi-
  51. character or keyword based flag. I have an Amiga version included, for
  52. example, that uses keyword syntax. In that version, the usage message reads:
  53.  
  54. Usage: amiga_test <name> [GROUP <newsgroup>]... [REP <repcount>] +
  55.     [DIR <dirname>] [X] [Y] [Z] [TAB <tabchar>] [<file>]...
  56.  
  57. Instead of:
  58.  
  59. Usage: unix_test <Name> [-n <newsGROUP>]... [-c <REPcount>] \
  60.     [-d <DIRname>] [-x] [-y] [-z] [-t <TABchar>] [<File>]...
  61.  
  62. This would solve the old problem of UNIX programs sticking out like a
  63. sore thumb in other operating systems.
  64.  
  65. The Amiga version still needs to prompt for options if called with a
  66. single '?' as an argument. Perhaps it will be possible to read options
  67. out of tooltypes and finally integrate CLI and Workbench environments.
  68.