Skip to content

Commit 0b1a006

Browse files
All platforms use a line-buffered stdout
Remove manual buffer flushing and setting of the buffer on stdout. Drop NOLINEBUF configuration point.
1 parent d42bb02 commit 0b1a006

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+454
-496
lines changed

HACKERSGUIDE.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ SYSTEM DEPENDENCIES AS DETERMINED BY THE CONFIGURE SCRIPT.
6060
* Don't use %d anywhere that someone might need a %ld. (Just because YOU
6161
typedefed it as an int doesn't mean someone else won't need a long.)
6262
* Don't use %D, that's archaic.
63-
* Put FLUSHes after printf()s, fputs()es and putchar('\n')s for our poor
64-
brethern and sistern without line buffering.
6563
* Declare the type of every function. Use void, even if your C compiler
6664
doesn't.
6765
* Follow the style that trn already uses! This is my pet peeve. Well, one

config/cmake/config.h.in

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@
1515
#cmakedefine HAS_NEWS_ADMIN
1616
#define NEWS_ADMIN "@NEWS_ADMIN@"
1717

18-
/* NOLINEBUF:
19-
* This symbol, if defined, indicates that stdout is not buffered, so that
20-
* the program can call setbuf() or setlinebuf() for efficiency.
21-
*/
22-
#cmakedefine NOLINEBUF
23-
2418
/* NORMSIG:
2519
* This symbol, if defined, indicates that normal signal handling routines
2620
* should be used, as opposed to the ones in 4.1bsd (sigset, etc.).

config/common.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -699,17 +699,4 @@ extern const char *g_cantopen;
699699
extern const char *g_cantcreate;
700700
extern const char *g_nocd;
701701

702-
#ifdef NOLINEBUF
703-
#define FLUSH ,fflush(stdout)
704-
#else
705-
#define FLUSH
706-
#endif
707-
708-
#ifdef lint
709-
#undef FLUSH
710-
#define FLUSH
711-
#undef putchar
712-
#define putchar(c)
713-
#endif
714-
715702
#endif

libtrn/addng.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static void new_nntp_groups(DATASRC *dp)
145145
break;
146146
#ifdef DEBUG
147147
if (debug & DEB_NNTP)
148-
printf("<%s\n", g_ser_line) FLUSH;
148+
printf("<%s\n", g_ser_line);
149149
#endif
150150
if (nntp_at_list_end(g_ser_line))
151151
break;
@@ -201,7 +201,7 @@ static void new_local_groups(DATASRC *dp)
201201

202202
FILE *fp = fopen(dp->extra_name, "r");
203203
if (fp == nullptr) {
204-
printf(g_cantopen,dp->extra_name) FLUSH;
204+
printf(g_cantopen, dp->extra_name);
205205
termdown(1);
206206
return;
207207
}

libtrn/art.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ page_switch_result page_switch()
723723
if (s != nullptr)
724724
{
725725
/* compile regular expression */
726-
printf("\n%s\n",s) FLUSH;
726+
printf("\n%s\n", s);
727727
termdown(2);
728728
return PS_ASK;
729729
}
@@ -740,8 +740,7 @@ page_switch_result page_switch()
740740
g_gline = g_tc_LINES-2;
741741
#ifdef DEBUG
742742
if (debug & DEB_INNERSRCH) {
743-
printf("Start here? %d >=? %d\n",g_topline + g_gline + 1,g_artline)
744-
FLUSH;
743+
printf("Start here? %d >=? %d\n",g_topline + g_gline + 1,g_artline);
745744
termdown(1);
746745
}
747746
#endif
@@ -767,7 +766,7 @@ page_switch_result page_switch()
767766
}
768767
#ifdef DEBUG
769768
if (debug & DEB_INNERSRCH)
770-
printf("Test %s\n",s) FLUSH;
769+
printf("Test %s\n",s);
771770
#endif
772771
success = execute(&s_gcompex,s) != nullptr;
773772
if (nlptr)
@@ -779,14 +778,13 @@ page_switch_result page_switch()
779778
}
780779
if (!g_innersearch) {
781780
seekartbuf(g_artpos);
782-
fputs("(Not found)",stdout) FLUSH;
781+
fputs("(Not found)", stdout);
783782
g_term_col = 11;
784783
return PS_ASK;
785784
}
786785
#ifdef DEBUG
787786
if (debug & DEB_INNERSRCH) {
788-
printf("On page? %ld <=? %ld\n",(long)g_innersearch,(long)g_artpos)
789-
FLUSH;
787+
printf("On page? %ld <=? %ld\n",(long)g_innersearch,(long)g_artpos);
790788
termdown(1);
791789
}
792790
#endif
@@ -799,7 +797,7 @@ page_switch_result page_switch()
799797
g_highlight = g_artline - 1;
800798
#ifdef DEBUG
801799
if (debug & DEB_INNERSRCH) {
802-
printf("@ %d\n",g_highlight) FLUSH;
800+
printf("@ %d\n",g_highlight);
803801
termdown(1);
804802
}
805803
#endif
@@ -829,7 +827,7 @@ page_switch_result page_switch()
829827
refresh_screen:
830828
#ifdef DEBUG
831829
if (debug & DEB_INNERSRCH) {
832-
printf("Topline = %d",g_topline) FLUSH;
830+
printf("Topline = %d",g_topline);
833831
fgets(g_buf, sizeof g_buf, stdin);
834832
}
835833
#endif
@@ -878,7 +876,7 @@ page_switch_result page_switch()
878876
for (pos = g_artpos - pos; pos-- && !at_nl(*s); s++)
879877
putchar(*s);
880878
color_default();
881-
putchar('\n') FLUSH;
879+
putchar('\n');
882880
g_topline--;
883881
g_artpos = vrdary(--g_artline);
884882
if (g_artpos < 0)
@@ -1061,7 +1059,7 @@ page_switch_result page_switch()
10611059
case 'q': /* quit this article? */
10621060
return PS_TOEND;
10631061
default:
1064-
fputs(g_hforhelp,stdout) FLUSH;
1062+
fputs(g_hforhelp,stdout);
10651063
termdown(1);
10661064
settle_down();
10671065
return PS_ASK;
@@ -1074,8 +1072,7 @@ bool innermore()
10741072
if (g_artpos < g_innersearch) { /* not even on page yet? */
10751073
#ifdef DEBUG
10761074
if (debug & DEB_INNERSRCH)
1077-
printf("Not on page %ld < %ld\n",(long)g_artpos,(long)g_innersearch)
1078-
FLUSH;
1075+
printf("Not on page %ld < %ld\n",(long)g_artpos,(long)g_innersearch);
10791076
#endif
10801077
return true;
10811078
}
@@ -1088,7 +1085,7 @@ bool innermore()
10881085
#ifdef DEBUG
10891086
if (debug & DEB_INNERSRCH) {
10901087
printf("There it is %ld = %ld, %d @ %d\n",(long)g_artpos,
1091-
(long)g_innersearch,g_hide_everything,g_highlight) FLUSH;
1088+
(long)g_innersearch,g_hide_everything,g_highlight);
10921089
termdown(1);
10931090
}
10941091
#endif
@@ -1101,8 +1098,7 @@ bool innermore()
11011098
}
11021099
#ifdef DEBUG
11031100
if (debug & DEB_INNERSRCH) {
1104-
printf("Not far enough? %d <? %d + %d\n",g_artline,s_isrchline,g_gline)
1105-
FLUSH;
1101+
printf("Not far enough? %d <? %d + %d\n",g_artline,s_isrchline,g_gline);
11061102
termdown(1);
11071103
}
11081104
#endif

libtrn/artsrch.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ art_search_result art_search(char *patbuf, int patbufsiz, bool get_cmd)
207207
}
208208
if (g_verbose) {
209209
if (cmdchr != '+' && cmdchr != '.')
210-
printf("\nMarking %s \"%s\" as read.\n",finding_str,h) FLUSH;
210+
printf("\nMarking %s \"%s\" as read.\n",finding_str,h);
211211
else
212-
printf("\nSelecting %s \"%s\".\n",finding_str,h) FLUSH;
212+
printf("\nSelecting %s \"%s\".\n",finding_str,h);
213213
termdown(2);
214214
}
215215
}
@@ -224,7 +224,7 @@ art_search_result art_search(char *patbuf, int patbufsiz, bool get_cmd)
224224
}
225225
#ifdef DEBUG
226226
if (debug) {
227-
printf("\npattern = %s\n",pattern) FLUSH;
227+
printf("\npattern = %s\n",pattern);
228228
termdown(2);
229229
}
230230
#endif
@@ -286,7 +286,7 @@ art_search_result art_search(char *patbuf, int patbufsiz, bool get_cmd)
286286
if (g_use_threads)
287287
newline();
288288
else {
289-
fputs("\nSearching...\n",stdout) FLUSH;
289+
fputs("\nSearching...\n",stdout);
290290
termdown(2);
291291
}
292292
/* give them something to read */
@@ -368,7 +368,7 @@ static bool wanted(COMPEX *compex, ART_NUM artnum, art_scope scope)
368368
strncpy(g_buf+9,fetchsubj(artnum,false),256);
369369
#ifdef DEBUG
370370
if (debug & DEB_SEARCH_AHEAD)
371-
printf("%s\n",g_buf) FLUSH;
371+
printf("%s\n",g_buf);
372372
#endif
373373
break;
374374
case ARTSCOPE_FROM:

libtrn/autosub.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static bool matchlist(const char *patlist, const char *s)
5656
const char *err = ng_comp(&ilcompex, pattern.c_str(), true, true);
5757

5858
if (err != nullptr) {
59-
printf("\n%s\n", err) FLUSH;
59+
printf("\n%s\n", err);
6060
finalize(1);
6161
}
6262

libtrn/backpage.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void backpage_init()
2424
s_varyfd = open(varyname,2);
2525
remove(varyname);
2626
if (s_varyfd < 0) {
27-
printf(g_cantopen,varyname) FLUSH;
27+
printf(g_cantopen,varyname);
2828
sig_catcher(0);
2929
}
3030

@@ -39,7 +39,7 @@ ART_POS vrdary(ART_LINE indx)
3939

4040
#ifdef DEBUG
4141
if (indx > maxindx) {
42-
printf("vrdary(%ld) > %ld\n",(long)indx, (long)maxindx) FLUSH;
42+
printf("vrdary(%ld) > %ld\n",(long)indx, (long)maxindx);
4343
return 0;
4444
}
4545
#endif
@@ -71,12 +71,12 @@ void vwtary(ART_LINE indx, ART_POS newvalue)
7171

7272
#ifdef DEBUG
7373
if (indx < 0)
74-
printf("vwtary(%ld)\n",(long)indx) FLUSH;
74+
printf("vwtary(%ld)\n",(long)indx);
7575
if (!indx)
7676
maxindx = 0;
7777
if (indx > maxindx) {
7878
if (indx != maxindx + 1)
79-
printf("indx skipped %d-%d\n",maxindx+1,indx-1) FLUSH;
79+
printf("indx skipped %d-%d\n",maxindx+1,indx-1);
8080
maxindx = indx;
8181
}
8282
#endif

libtrn/bits.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ void rc_to_bits()
7676
unread = 0;
7777
#ifdef DEBUG
7878
if (debug & DEB_CTLAREA_BITMAP) {
79-
printf("\n%s\n",mybuf) FLUSH;
79+
printf("\n%s\n",mybuf);
8080
termdown(2);
8181
for (i = article_first(g_absfirst); i < g_firstart; i = article_next(i)) {
8282
if (article_unread(i))
83-
printf("%ld ",(long)i) FLUSH;
83+
printf("%ld ",(long)i);
8484
}
8585
}
8686
#endif
@@ -118,11 +118,11 @@ void rc_to_bits()
118118
article_ptr(i)->flags &= ~AF_UNREAD;
119119
#ifdef DEBUG
120120
if (debug & DEB_CTLAREA_BITMAP) {
121-
printf("\n%s\n",s) FLUSH;
121+
printf("\n%s\n",s);
122122
termdown(2);
123123
for (i = g_absfirst; i <= g_lastart; i++) {
124124
if (!was_read(i))
125-
printf("%ld ",(long)i) FLUSH;
125+
printf("%ld ",(long)i);
126126
}
127127
}
128128
#endif
@@ -143,7 +143,7 @@ void rc_to_bits()
143143
}
144144
#ifdef DEBUG
145145
if (debug & DEB_CTLAREA_BITMAP) {
146-
fputs("\n(hit CR)",stdout) FLUSH;
146+
fputs("\n(hit CR)",stdout);
147147
termdown(1);
148148
fgets(g_cmd_buf, sizeof g_cmd_buf, stdin);
149149
}
@@ -225,8 +225,8 @@ void bits_to_rc()
225225
*s++ = '\0'; /* and terminate string */
226226
#ifdef DEBUG
227227
if ((debug & DEB_NEWSRC_LINE) && !g_panic) {
228-
printf("%s: %s\n",g_ngptr->rcline,g_ngptr->rcline+g_ngptr->numoffset) FLUSH;
229-
printf("%s\n",mybuf) FLUSH;
228+
printf("%s: %s\n",g_ngptr->rcline,g_ngptr->rcline+g_ngptr->numoffset);
229+
printf("%s\n",mybuf);
230230
termdown(2);
231231
}
232232
#endif
@@ -506,7 +506,7 @@ void yankback()
506506
plural(g_dmcount));
507507
else {
508508
printf("\nReturning %ld Marked article%s...\n",(long)g_dmcount,
509-
plural(g_dmcount)) FLUSH;
509+
plural(g_dmcount));
510510
termdown(2);
511511
}
512512
article_walk(yank_article, 0);
@@ -596,7 +596,7 @@ static int chase_xref(ART_NUM artnum, int markread)
596596
xref_buf = savestr(xref_buf);
597597
# ifdef DEBUG
598598
if (debug & DEB_XREF_MARKER) {
599-
printf("Xref: %s\n",xref_buf) FLUSH;
599+
printf("Xref: %s\n",xref_buf);
600600
termdown(1);
601601
}
602602
# endif
@@ -688,7 +688,7 @@ static bool valid_xref_site(ART_NUM artnum, char *site)
688688

689689
#ifdef DEBUG
690690
if (debug) {
691-
printf("Xref not from %s -- ignoring\n",inews_site) FLUSH;
691+
printf("Xref not from %s -- ignoring\n",inews_site);
692692
termdown(1);
693693
}
694694
#endif

libtrn/cache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ void look_ahead()
662662
if (s != nullptr)
663663
{
664664
/* compile regular expression */
665-
printf("\n%s\n",s) FLUSH;
665+
printf("\n%s\n",s);
666666
termdown(2);
667667
g_srchahead = 0;
668668
}

0 commit comments

Comments
 (0)