home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d8xx / d848 / cweb.lha / CWeb / CWeb27.lha / examples / wmerge-p.ch < prev    next >
Encoding:
Text File  |  1993-03-16  |  6.0 KB  |  199 lines

  1.                                 -*-Web-*-
  2. This file, WMERGE-P.CH, is part of CWEB-p. It is a changefile written by
  3. Hans-Hermann Bode (HHBODE@@DOSUNI1.BITNET or
  4. hhbode@@dosuni1.rz.uni-osnabrueck.de) for WMERGE.W that provides changes
  5. appropriate for ANSI-C compilers and for the Turbo-C++ compiler. The latter
  6. will become effective only if the symbol __TURBOC__ is defined, which
  7. automatically is the case when compiled with Turbo C++. Also there are some
  8. changes appropriate for the SAS/C 6.0 compiler. These will become
  9. effective only if the symbol __SASC is defined, which automatically is the
  10. case when compiled with SAS/C 6.0 or higher.
  11.  
  12. This program is distributed WITHOUT ANY WARRANTY, express or implied.
  13.  
  14. The following copyright notice extends to this changefile only, not to the
  15. masterfile.
  16.  
  17. Copyright (C) 1992 Hans-Hermann Bode
  18.  
  19. The following copyright notice extends to the SAS/C specific changes only,
  20. not to the masterfile.
  21.  
  22. Copyright (C) 1993 Andreas Scherer
  23.  
  24. Permission is granted to make and distribute verbatim copies of this
  25. document provided that the copyright notice and this permission notice
  26. are preserved on all copies.
  27.  
  28. Permission is granted to copy and distribute modified versions of this
  29. document under the conditions for verbatim copying, provided that the
  30. entire resulting derived work is distributed under the terms of a
  31. permission notice identical to this one.
  32.  
  33. Version history:
  34.  
  35. Version    Date        Author    Comment
  36. p2    13 Feb 1992    H2B    First hack.
  37. p3    16 Apr 1992    H2B    Change of |@@i| allowed, /dev/null in case
  38.                 replaced by nul.
  39. p4    21 Jun 1992    H2B    Nothing changed.
  40. p5    21 Jul 1992    H2B    Nothing changed.
  41. p5a    30 Jul 1992    KG    remove one #include <stdio.h>,
  42.                 use strchr instead of index and
  43.                 include <string.h> for |strchr| declaration
  44. p5b    06 Aug 1992    KG    fixed a typo
  45. p6    06 Sep 1992    H2B    Nothing changed.
  46. p6a     15 Mar 1993     AS      SAS/C 6.0 support
  47. ------------------------------------------------------------------------------
  48. The |index| function is not ANSI but |strchr| is equivalent.
  49. |strchr| should be declared in <string.h>
  50. Also avoid ';' between functions, and make definition of main conform
  51. to ANSI C.
  52. @x l.9
  53. #include <stdio.h>
  54. @<Definitions@>@;
  55. @<Functions@>;
  56. @y
  57. #include <stdio.h>
  58. #include <string.h>
  59. #include <stdlib.h>
  60. @<Definitions@>@;
  61. @<Prototypes@>@;
  62. @<Functions@>@;
  63. @z
  64. ------------------------------------------------------------------------------
  65. @x l.26
  66. @ @<Definitions@>=
  67. typedef short boolean;
  68. typedef char unsigned eight_bits;
  69. typedef char ASCII; /* type of characters inside \.{WEB} */
  70. @y
  71. @ @<Definitions@>=
  72. typedef short boolean;
  73. #ifdef __SASC
  74. typedef unsigned char eight_bits;
  75. #else
  76. typedef char unsigned eight_bits;
  77. #endif
  78. typedef char ASCII; /* type of characters inside \.{WEB} */
  79. @z
  80. ------------------------------------------------------------------------------
  81. @x l. 75
  82. these will make {\bf caddr\_t} be treated in the same way as |int|. 
  83.  
  84. @<Func...@>=
  85. #include <stdio.h>
  86. @y
  87. these will make {\bf caddr\_t} be treated in the same way as |int|. 
  88.  
  89. The file \.{stdio.h} has been included already at the very beginning.
  90. @<Func...@>=
  91. @z
  92. ------------------------------------------------------------------------------
  93. @x l.180
  94. @ We do not allow includes in a change file, so as to avoid confusion.
  95. @y
  96. @ We do not allow includes in a change file, so as to avoid confusion.
  97. Actually, the following check will be applied to comment lines in the change
  98. file only, since otherwise \.{@@i} commands could never be changed.
  99. @z
  100. ------------------------------------------------------------------------------
  101. We like to be able to change @@i commands, also.
  102. @x l.230
  103.     if (limit>buffer+1 && buffer[0]==@'@@')
  104.       @<Check for erron...@>;
  105. @y
  106. @z
  107. ------------------------------------------------------------------------------
  108. SAS/C defines `putchar' as a macro and reports a warning about multiple
  109. macro expansion.  The resulting `wmerge' is definitively wrong; it leaves
  110. every second letter out.
  111. @x l.329
  112. put_line()
  113. {
  114.   char *ptr=buffer;
  115.   while (ptr<limit) putchar(*ptr++);
  116.   putchar('\n');
  117. }
  118. @y
  119. put_line()
  120. {
  121.   char *ptr=buffer;
  122.   while (ptr<limit)
  123.   {
  124.     putchar(*ptr);
  125.     *ptr++;
  126.   }
  127.   putchar('\n');
  128. }
  129. @z
  130. ------------------------------------------------------------------------------
  131. We like to be able to change @@i commands, also.
  132. @x l.391
  133.     @<Check for erron...@>;
  134. @y
  135. @z
  136. ------------------------------------------------------------------------------
  137. @x l.540
  138. An omitted change file argument means that |'/dev/null'| should be used,
  139. @y
  140. An omitted change file argument means that |'/dev/null'| or---on {\mc
  141. MS-DOS} systems---|'nul'| or---on {\mc AMIGA} systems---|'NIL:'|
  142. should be used,
  143. @z
  144. ------------------------------------------------------------------------------
  145. |index| is a BSD function, not used in ANSI C.
  146. To avoid conflicting declarations when using prototypes,
  147. remove the declaration here.
  148. @x l.544
  149.   char *dot_pos, *index(); /* position of |'.'| in the argument */
  150. @y
  151.   char *dot_pos; /* position of |'.'| in the argument */
  152. @z
  153. ------------------------------------------------------------------------------
  154. use the standard conforming |strchr| instead of BSD's |index|
  155. @x l.574
  156.   if ((dot_pos=index(*argv,'.'))==NULL)
  157. @y
  158.   if ((dot_pos=strchr(*argv,'.'))==NULL)
  159. @z
  160.  
  161. @x l.586
  162.   if ((dot_pos=index(*argv,'.'))==NULL)
  163. @y
  164.   if ((dot_pos=strchr(*argv,'.'))==NULL)
  165. @z
  166. ------------------------------------------------------------------------------
  167. @x l.593
  168. @ @<Set up null...@>= strcpy(change_file_name,"/dev/null");
  169. @y
  170. @ @<Set up null...@>=
  171. #if defined( __TURBOC__ )
  172.   strcpy(change_file_name,"nul");
  173. #elif defined( __SASC )
  174.   strcpy(change_file_name,"NIL:");
  175. #else
  176.   strcpy(change_file_name,"/dev/null");
  177. #endif
  178. @z
  179. ------------------------------------------------------------------------------
  180. @x l.???
  181. @* Index.
  182. @y
  183. @<Proto...@>=
  184. int input_ln(FILE *fp);
  185. int prime_the_change_buffer(void);
  186. int check_change(void);
  187. int reset_input(void);
  188. int get_line(void);
  189. int put_line(void);
  190. int check_complete(void);
  191. int err_print(char *s);
  192. int wrap_up(void);
  193. int scan_args(int argc,char **argv);
  194. int main(int argc,char **argv);
  195.  
  196. @* Index.
  197. @z
  198. ------------------------------------------------------------------------------
  199.