home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / apple2 / 39 < prev    next >
Encoding:
Text File  |  1990-12-02  |  2.0 KB  |  110 lines

  1. Path: wuarchive!uwm.edu!rutgers!aramis.rutgers.edu!paul.rutgers.edu!yoko.rutgers.edu!jac
  2. From: jac@yoko.rutgers.edu (Jonathan A. Chandross)
  3. Newsgroups: comp.sources.apple2
  4. Subject: v001SRC016:  show -- Display Non-Printing Characters
  5. Message-ID: <Dec.1.16.56.01.1990.24824@yoko.rutgers.edu>
  6. Date: 1 Dec 90 21:56:01 GMT
  7. Organization: Rutgers Univ., New Brunswick, N.J.
  8. Lines: 99
  9. Approved: jac@paul.rutgers.edu
  10.  
  11.  
  12. Submitted-by: NONE
  13. Posting-number: Volume 1, Source:16
  14. Archive-name: util/show
  15. Architecture: ANY_2
  16. Version-number: 1.00
  17.  
  18. This utility displays non-rpinting characters in a file.
  19.  
  20. Enjoy.
  21.  
  22.  
  23. =show.c
  24. -
  25. -/*
  26. - * show.c
  27. - *
  28. - * Display non-printing chars in a file.
  29. - *    Non-printing character mappings:
  30. - *        CHARACTER    DISPLAYED AS
  31. - *         tab         >
  32. - *         newline     $
  33. - *         control X     ~X    where X is any control character
  34. - *         delete         ~~
  35. - *     Newlines and tabs are also echoed to output as control characters.
  36. - *
  37. - * Usage:
  38. - *     show [file_1] [file_2] [file_3] [...]
  39. - *
  40. - *     If no file is specified, show reads from standard in. 
  41. - *
  42. - * Contributed Anonymously.  Written: November 1983
  43. - *
  44. - * Version 1.00
  45. - *
  46. - */
  47. -
  48. -#include "stdio.h"
  49. -
  50. -#define BLANK ' '
  51. -#define TAB   '\t'
  52. -#define NL    '\n'
  53. -
  54. -main(argc, argv)
  55. -int argc ;
  56. -char *argv[] ;
  57. -{
  58. -    FILE *input ;
  59. -
  60. -
  61. -    argc-- ; argv++ ;
  62. -
  63. -    if( argc == 0 )
  64. -        show( stdin ) ;
  65. -
  66. -    else
  67. -        for( ; argc>0 ; argc--,argv++)
  68. -            if( (input=fopen(*argv,"r")) == NULL ) {
  69. -                fprintf(stderr, "show: can't open %s\n", *argv) ;
  70. -                exit(1) ;
  71. -            }
  72. -            else {
  73. -                show(input) ;
  74. -                fclose( input ) ;
  75. -            }
  76. -
  77. -    exit(0) ;
  78. -
  79. -} /* end main */
  80. -
  81. -/* show - print invisible chars */
  82. -
  83. -show( in )
  84. -FILE *in ;
  85. -{
  86. -    int c ;
  87. -
  88. -
  89. -    while( (c=agetc(in)) != EOF )
  90. -        if( c == NL ) {
  91. -            aputc( '$', stdout ) ;
  92. -            aputc( NL, stdout ) ;
  93. -        }
  94. -        else if( c == TAB )
  95. -            aputc( '>', stdout ) ;
  96. -        else if( c < BLANK ) {
  97. -            aputc( '~', stdout ) ;
  98. -            aputc( c+'@', stdout ) ;
  99. -        }
  100. -        else if( c == 0x7f ) {
  101. -            aputc( '~', stdout ) ;
  102. -            aputc( '~', stdout ) ;
  103. -        }
  104. -        else
  105. -            aputc( c, stdout ) ;
  106. -
  107. -} /* end show */
  108. -
  109. + END OF ARCHIVE
  110.