Nicholas Marriott wrote: > I like the idea, but I don't like calling them ap_off_t and offttoa, > I'd just keep ap_pos and postoa and remove the linenum functions.
Does this look good? Index: less.h =================================================================== RCS file: /cvs/src/usr.bin/less/less.h,v retrieving revision 1.21 diff -u -p -r1.21 less.h --- less.h 12 Jan 2016 17:48:04 -0000 1.21 +++ less.h 13 Jan 2016 22:40:49 -0000 @@ -206,5 +206,4 @@ struct textlist { /* Functions not included in funcs.h */ void postoa(off_t, char *, size_t); -void linenumtoa(off_t, char *, size_t); void inttoa(int, char *, size_t); Index: line.c =================================================================== RCS file: /cvs/src/usr.bin/less/line.c,v retrieving revision 1.16 diff -u -p -r1.16 line.c --- line.c 12 Jan 2016 17:48:04 -0000 1.16 +++ line.c 13 Jan 2016 22:40:49 -0000 @@ -178,7 +178,7 @@ plinenum(off_t pos) char buf[INT_STRLEN_BOUND(pos) + 2]; int n; - linenumtoa(linenum, buf, sizeof (buf)); + postoa(linenum, buf, sizeof(buf)); n = strlen(buf); if (n < MIN_LINENUM_WIDTH) n = MIN_LINENUM_WIDTH; Index: output.c =================================================================== RCS file: /cvs/src/usr.bin/less/output.c,v retrieving revision 1.14 diff -u -p -r1.14 output.c --- output.c 12 Jan 2016 17:48:04 -0000 1.14 +++ output.c 13 Jan 2016 22:40:50 -0000 @@ -149,7 +149,6 @@ funcname(type num, char *buf, size_t len } TYPE_TO_A_FUNC(postoa, off_t) -TYPE_TO_A_FUNC(linenumtoa, off_t) TYPE_TO_A_FUNC(inttoa, int) /* @@ -173,7 +172,7 @@ iprint_linenum(off_t num) { char buf[INT_STRLEN_BOUND(num)]; - linenumtoa(num, buf, sizeof (buf)); + postoa(num, buf, sizeof(buf)); putstr(buf); return (strlen(buf)); } Index: prompt.c =================================================================== RCS file: /cvs/src/usr.bin/less/prompt.c,v retrieving revision 1.19 diff -u -p -r1.19 prompt.c --- prompt.c 12 Jan 2016 23:01:23 -0000 1.19 +++ prompt.c 13 Jan 2016 22:40:50 -0000 @@ -120,19 +120,7 @@ ap_pos(off_t pos) { char buf[INT_STRLEN_BOUND(pos) + 2]; - postoa(pos, buf, sizeof buf); - ap_str(buf); -} - -/* - * Append a line number to the end of the message. - */ -static void -ap_linenum(off_t linenum) -{ - char buf[INT_STRLEN_BOUND(linenum) + 2]; - - linenumtoa(linenum, buf, sizeof buf); + postoa(pos, buf, sizeof(buf)); ap_str(buf); } @@ -255,7 +243,7 @@ protochar(int c, int where) case 'd': /* Current page number */ linenum = currline(where); if (linenum > 0 && sc_height > 1) - ap_linenum(PAGE_NUM(linenum)); + ap_pos(PAGE_NUM(linenum)); else ap_quest(); break; @@ -266,13 +254,13 @@ protochar(int c, int where) ap_quest(); } else if (len == 0) { /* An empty file has no pages. */ - ap_linenum(0); + ap_pos(0); } else { linenum = find_linenum(len - 1); if (linenum <= 0) ap_quest(); else - ap_linenum(PAGE_NUM(linenum)); + ap_pos(PAGE_NUM(linenum)); } break; case 'E': /* Editor name */ @@ -293,7 +281,7 @@ protochar(int c, int where) case 'l': /* Current line number */ linenum = currline(where); if (linenum != 0) - ap_linenum(linenum); + ap_pos(linenum); else ap_quest(); break; @@ -303,7 +291,7 @@ protochar(int c, int where) (linenum = find_linenum(len)) <= 0) ap_quest(); else - ap_linenum(linenum-1); + ap_pos(linenum-1); break; case 'm': /* Number of files */ n = ntags();