Replace-getline-with-get_line.patch 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. From: Tobias Quathamer <toddy@debian.org>
  2. Date: Thu, 16 Feb 2012 11:26:00 +0100
  3. Subject: Replace getline() with get_line()
  4. ---
  5. boggle/boggle/bog.c | 2 +-
  6. boggle/boggle/extern.h | 2 +-
  7. boggle/boggle/mach.c | 2 +-
  8. cribbage/crib.c | 4 ++--
  9. cribbage/cribbage.h | 2 +-
  10. cribbage/io.c | 8 ++++----
  11. gomoku/bdisp.c | 2 +-
  12. gomoku/gomoku.h | 2 +-
  13. gomoku/main.c | 14 +++++++-------
  14. 9 files changed, 19 insertions(+), 19 deletions(-)
  15. diff --git a/boggle/boggle/bog.c b/boggle/boggle/bog.c
  16. index 276969b..0aaa086 100644
  17. --- a/boggle/boggle/bog.c
  18. +++ b/boggle/boggle/bog.c
  19. @@ -336,7 +336,7 @@ playgame()
  20. }
  21. while (1) {
  22. - if (getline(buf) == NULL) {
  23. + if (get_line(buf) == NULL) {
  24. if (feof(stdin))
  25. clearerr(stdin);
  26. break;
  27. diff --git a/boggle/boggle/extern.h b/boggle/boggle/extern.h
  28. index ba36561..734a4b9 100644
  29. --- a/boggle/boggle/extern.h
  30. +++ b/boggle/boggle/extern.h
  31. @@ -43,7 +43,7 @@ void delay(int);
  32. long dictseek(FILE *, long, int);
  33. void findword(void);
  34. void flushin(FILE *);
  35. -char *getline(char *);
  36. +char *get_line(char *);
  37. void getword(char *);
  38. int help(void);
  39. int inputch(void);
  40. diff --git a/boggle/boggle/mach.c b/boggle/boggle/mach.c
  41. index b511296..dd89578 100644
  42. --- a/boggle/boggle/mach.c
  43. +++ b/boggle/boggle/mach.c
  44. @@ -168,7 +168,7 @@ prwidth(base, indx)
  45. * - doesn't accept words longer than MAXWORDLEN or containing caps
  46. */
  47. char *
  48. -getline(q)
  49. +get_line(q)
  50. char *q;
  51. {
  52. int ch, done;
  53. diff --git a/cribbage/crib.c b/cribbage/crib.c
  54. index 5fc53b3..9340126 100644
  55. --- a/cribbage/crib.c
  56. +++ b/cribbage/crib.c
  57. @@ -221,7 +221,7 @@ game()
  58. if (!rflag) { /* player cuts deck */
  59. msg(quiet ? "Cut for crib? " :
  60. "Cut to see whose crib it is -- low card wins? ");
  61. - getline();
  62. + get_line();
  63. }
  64. i = (rand() >> 4) % CARDS; /* random cut */
  65. do { /* comp cuts deck */
  66. @@ -397,7 +397,7 @@ cut(mycrib, pos)
  67. if (!rflag) { /* random cut */
  68. msg(quiet ? "Cut the deck? " :
  69. "How many cards down do you wish to cut the deck? ");
  70. - getline();
  71. + get_line();
  72. }
  73. i = (rand() >> 4) % (CARDS - pos);
  74. turnover = deck[i + pos];
  75. diff --git a/cribbage/cribbage.h b/cribbage/cribbage.h
  76. index ce2eecb..3187457 100644
  77. --- a/cribbage/cribbage.h
  78. +++ b/cribbage/cribbage.h
  79. @@ -77,7 +77,7 @@ int eq(CARD, CARD);
  80. int fifteens(const CARD [], int);
  81. void game(void);
  82. void gamescore(void);
  83. -char *getline(void);
  84. +char *get_line(void);
  85. int getuchar(void);
  86. int incard(CARD *);
  87. int infrom(const CARD [], int, const char *);
  88. diff --git a/cribbage/io.c b/cribbage/io.c
  89. index 3d69257..8100ddd 100644
  90. --- a/cribbage/io.c
  91. +++ b/cribbage/io.c
  92. @@ -245,7 +245,7 @@ incard(crd)
  93. retval = FALSE;
  94. rnk = sut = EMPTY;
  95. - if (!(line = getline()))
  96. + if (!(line = get_line()))
  97. goto gotit;
  98. p = p1 = line;
  99. while (*p1 != ' ' && *p1 != '\0')
  100. @@ -346,7 +346,7 @@ number(lo, hi, prompt)
  101. for (sum = 0;;) {
  102. msg(prompt);
  103. - if (!(p = getline()) || *p == '\0') {
  104. + if (!(p = get_line()) || *p == '\0') {
  105. msg(quiet ? "Not a number" :
  106. "That doesn't look like a number");
  107. continue;
  108. @@ -528,12 +528,12 @@ over:
  109. }
  110. /*
  111. - * getline:
  112. + * get_line:
  113. * Reads the next line up to '\n' or EOF. Multiple spaces are
  114. * compressed to one space; a space is inserted before a ','
  115. */
  116. char *
  117. -getline()
  118. +get_line()
  119. {
  120. char *sp;
  121. int c, oy, ox;
  122. diff --git a/gomoku/bdisp.c b/gomoku/bdisp.c
  123. index 522d92f..d2de746 100644
  124. --- a/gomoku/bdisp.c
  125. +++ b/gomoku/bdisp.c
  126. @@ -241,7 +241,7 @@ ask(str)
  127. }
  128. int
  129. -getline(buf, size)
  130. +get_line(buf, size)
  131. char *buf;
  132. int size;
  133. {
  134. diff --git a/gomoku/gomoku.h b/gomoku/gomoku.h
  135. index 0d9ff6e..3ebb42e 100644
  136. --- a/gomoku/gomoku.h
  137. +++ b/gomoku/gomoku.h
  138. @@ -263,7 +263,7 @@ extern int debug;
  139. void bdinit(struct spotstr *);
  140. void init_overlap(void);
  141. -int getline(char *, int);
  142. +int get_line(char *, int);
  143. void ask(const char *);
  144. void dislog(const char *);
  145. void bdump(FILE *);
  146. diff --git a/gomoku/main.c b/gomoku/main.c
  147. index 299dee1..3ff4750 100644
  148. --- a/gomoku/main.c
  149. +++ b/gomoku/main.c
  150. @@ -155,7 +155,7 @@ again:
  151. if (inputfp == NULL && test == 0) {
  152. for (;;) {
  153. ask("black or white? ");
  154. - getline(buf, sizeof(buf));
  155. + get_line(buf, sizeof(buf));
  156. if (buf[0] == 'b' || buf[0] == 'B') {
  157. color = BLACK;
  158. break;
  159. @@ -172,7 +172,7 @@ again:
  160. }
  161. } else {
  162. setbuf(stdout, 0);
  163. - getline(buf, sizeof(buf));
  164. + get_line(buf, sizeof(buf));
  165. if (strcmp(buf, "black") == 0)
  166. color = BLACK;
  167. else if (strcmp(buf, "white") == 0)
  168. @@ -244,7 +244,7 @@ again:
  169. getinput:
  170. if (interactive)
  171. ask("move? ");
  172. - if (!getline(buf, sizeof(buf))) {
  173. + if (!get_line(buf, sizeof(buf))) {
  174. curmove = RESIGN;
  175. break;
  176. }
  177. @@ -256,7 +256,7 @@ again:
  178. FILE *fp;
  179. ask("save file name? ");
  180. - (void)getline(buf, sizeof(buf));
  181. + (void)get_line(buf, sizeof(buf));
  182. if ((fp = fopen(buf, "w")) == NULL) {
  183. glog("cannot create save file");
  184. goto getinput;
  185. @@ -309,14 +309,14 @@ again:
  186. if (i != RESIGN) {
  187. replay:
  188. ask("replay? ");
  189. - if (getline(buf, sizeof(buf)) &&
  190. + if (get_line(buf, sizeof(buf)) &&
  191. (buf[0] == 'y' || buf[0] == 'Y'))
  192. goto again;
  193. if (strcmp(buf, "save") == 0) {
  194. FILE *fp;
  195. ask("save file name? ");
  196. - (void)getline(buf, sizeof(buf));
  197. + (void)get_line(buf, sizeof(buf));
  198. if ((fp = fopen(buf, "w")) == NULL) {
  199. glog("cannot create save file");
  200. goto replay;
  201. @@ -367,7 +367,7 @@ whatsup(signum)
  202. quit();
  203. top:
  204. ask("cmd? ");
  205. - if (!getline(fmtbuf, sizeof(fmtbuf)))
  206. + if (!get_line(fmtbuf, sizeof(fmtbuf)))
  207. quit();
  208. switch (*fmtbuf) {
  209. case '\0':
  210. --