diff options
Diffstat (limited to 'text-utils')
-rw-r--r-- | text-utils/Makefile | 28 | ||||
-rw-r--r-- | text-utils/col.c | 21 | ||||
-rw-r--r-- | text-utils/colcrt.c | 11 | ||||
-rw-r--r-- | text-utils/colrm.c | 4 | ||||
-rw-r--r-- | text-utils/column.c | 12 | ||||
-rw-r--r-- | text-utils/hexdump.c | 9 | ||||
-rw-r--r-- | text-utils/hexsyntax.c | 11 | ||||
-rw-r--r-- | text-utils/more.c | 342 | ||||
-rw-r--r-- | text-utils/more.help.cs | 28 | ||||
-rw-r--r-- | text-utils/odsyntax.c | 11 | ||||
-rw-r--r-- | text-utils/parse.c | 19 | ||||
-rw-r--r-- | text-utils/rev.c | 12 | ||||
-rw-r--r-- | text-utils/ul.c | 22 |
13 files changed, 381 insertions, 149 deletions
diff --git a/text-utils/Makefile b/text-utils/Makefile index 686418d61..66fda287e 100644 --- a/text-utils/Makefile +++ b/text-utils/Makefile @@ -3,38 +3,50 @@ # Revised: Mon Aug 19 20:11:15 1996 by faith@cs.unc.edu # Copyright 1992, 1993, 1994, 1995 Rickard E. Faith (faith@cs.unc.edu) # - +include ../make_include include ../MCONFIG # Where to put man pages? -MAN1= col.1 colcrt.1 colrm.1 column.1 hexdump.1 more.1 rev.1 \ - ul.1 +MAN1= col.1 colcrt.1 colrm.1 column.1 hexdump.1 more.1 rev.1 # Where to put binaries? # See the "install" rule for the links. . . BIN= more -USRBIN= col colcrt colrm column hexdump rev ul +USRBIN= col colcrt colrm column hexdump rev + +ifeq "$(HAVE_NCURSES)" "yes" +USRBIN:=$(USRBIN) ul +MAN1:=$(MAN1) ul.1 +endif # Where to put datebase files? USRLIB= more.help +all: $(BIN) $(USRBIN) + # Programs requiring special compilation -NEEDS_NCURSES= more ul +NEEDS_NCURSES= ul -all: $(BIN) $(USRBIN) +ifeq "$(HAVE_TERMCAP)" "no" +NEEDS_NCURSES:=$(NEEDS_NCURSES) more +else +more: + $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ $(LIBTERMCAP) +endif $(NEEDS_NCURSES): ifeq "$(HAVE_NCURSES)" "yes" - $(CC) $(LDFLAGS) $^ -o $@ $(LIBCURSES) + $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ $(LIBCURSES) else @echo $@ not made since it requires ncurses endif + # Rules for hexdump hexdump: hexdump.o conv.o display.o hexsyntax.o odsyntax.o parse.o @@ -51,11 +63,11 @@ col: col.o colcrt: colcrt.o colrm: colrm.o column: column.o $(ERR_O) +more: more.o more.o: more.c $(LIB)/pathnames.h rev: rev.o ifeq "$(HAVE_NCURSES)" "yes" -more: more.o ul: ul.o endif diff --git a/text-utils/col.c b/text-utils/col.c index 1cbaeb5b1..f08f51ad8 100644 --- a/text-utils/col.c +++ b/text-utils/col.c @@ -37,6 +37,9 @@ * patches from Andries.Brouwer@cwi.nl * Wed Sep 14 22:31:17 1994: patches from Carl Christofferson * (cchris@connected.com) + * 1999-02-22 Arkadiusz Miśkiewicz <misiek@misiek.eu.org> + * - added Native Language Support + * */ #include <stdlib.h> @@ -46,6 +49,7 @@ #include <string.h> #include <stdio.h> #include <unistd.h> +#include "nls.h" #include <locale.h> #define BS '\b' /* backspace */ @@ -123,9 +127,10 @@ int main(int argc, char **argv) int nflushd_lines; /* number of lines that were flushed */ int adjust, opt, warned; - /* we discard characters that do not pass isgraph() */ - setlocale(LC_CTYPE, ""); - + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + max_bufd_lines = 128; compress_spaces = 1; /* compress spaces into tabs */ while ((opt = getopt(argc, argv, "bfhl:x")) != EOF) @@ -142,7 +147,7 @@ int main(int argc, char **argv) case 'l': /* buffered line count */ if ((max_bufd_lines = atoi(optarg)) <= 0) { (void)fprintf(stderr, - "col: bad -l argument %s.\n", optarg); + _("col: bad -l argument %s.\n"), optarg); exit(1); } break; @@ -503,19 +508,19 @@ xmalloc(void *p, size_t size) void usage() { - (void)fprintf(stderr, "usage: col [-bfx] [-l nline]\n"); + (void)fprintf(stderr, _("usage: col [-bfx] [-l nline]\n")); exit(1); } void wrerr() { - (void)fprintf(stderr, "col: write error.\n"); + (void)fprintf(stderr, _("col: write error.\n")); exit(1); } void warn(int line) { (void)fprintf(stderr, - "col: warning: can't back up %s.\n", line < 0 ? - "past first line" : "-- line already flushed"); + _("col: warning: can't back up %s.\n"), line < 0 ? + _("past first line") : _("-- line already flushed")); } diff --git a/text-utils/colcrt.c b/text-utils/colcrt.c index f21f76927..1620c2737 100644 --- a/text-utils/colcrt.c +++ b/text-utils/colcrt.c @@ -31,9 +31,14 @@ * SUCH DAMAGE. */ + /* 1999-02-22 Arkadiusz Miśkiewicz <misiek@misiek.eu.org> + * - added Native Language Support + */ + #include <stdio.h> #include <unistd.h> /* for close() */ #include <string.h> +#include "nls.h" int plus(char c, char d); void move(int l, int m); @@ -70,6 +75,10 @@ main(int argc, char **argv) int c; char *cp, *dp; + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + argc--; progname = *argv++; while (argc > 0 && argv[0][0] == '-') { @@ -81,7 +90,7 @@ main(int argc, char **argv) printall = 1; break; default: - printf("usage: %s [ - ] [ -2 ] [ file ... ]\n", progname); + printf(_("usage: %s [ - ] [ -2 ] [ file ... ]\n"), progname); fflush(stdout); exit(1); } diff --git a/text-utils/colrm.c b/text-utils/colrm.c index f189e25d2..b17b8fb32 100644 --- a/text-utils/colrm.c +++ b/text-utils/colrm.c @@ -31,6 +31,10 @@ * SUCH DAMAGE. */ + /* 1999-02-22 Arkadiusz Miśkiewicz <misiek@misiek.eu.org> + * - added Native Language Support + */ + #include <stdio.h> /* diff --git a/text-utils/column.c b/text-utils/column.c index 4ae9522ef..21236b2c8 100644 --- a/text-utils/column.c +++ b/text-utils/column.c @@ -30,6 +30,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ + +/* 1999-02-22 Arkadiusz Miśkiewicz <misiek@misiek.eu.org> + * - added Native Language Support + */ #include <sys/types.h> #include <sys/ioctl.h> @@ -41,6 +45,7 @@ #include <unistd.h> #include <stdlib.h> #include <string.h> +#include "nls.h" void c_columnate __P((void)); void *emalloc __P((int)); @@ -74,6 +79,9 @@ main(argc, argv) extern char *__progname; __progname = argv[0]; #endif + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); if (ioctl(1, TIOCGWINSZ, &win) == -1 || !win.ws_col) { if ((p = getenv("COLUMNS")) != NULL) @@ -265,7 +273,7 @@ input(fp) if (!*p) continue; if (!(p = strchr(p, '\n'))) { - warnx("line too long"); + warnx(_("line too long")); eval = 1; continue; } @@ -300,6 +308,6 @@ usage() { (void)fprintf(stderr, - "usage: column [-tx] [-c columns] [file ...]\n"); + _("usage: column [-tx] [-c columns] [file ...]\n")); exit(1); } diff --git a/text-utils/hexdump.c b/text-utils/hexdump.c index 2b3b1bf70..a2be19038 100644 --- a/text-utils/hexdump.c +++ b/text-utils/hexdump.c @@ -31,9 +31,14 @@ * SUCH DAMAGE. */ + /* 1999-02-22 Arkadiusz Miśkiewicz <misiek@misiek.eu.org> + * - added Native Language Support + */ + #include <sys/types.h> #include <stdio.h> #include "hexdump.h" +#include "nls.h" FS *fshead; /* head of format strings */ int blocksize; /* data block size */ @@ -47,6 +52,10 @@ int main(argc, argv) register FS *tfs; char *p, *rindex(); + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + if (!(p = rindex(argv[0], 'o')) || strcmp(p, "od")) newsyntax(argc, &argv); else diff --git a/text-utils/hexsyntax.c b/text-utils/hexsyntax.c index 136716011..e376b0664 100644 --- a/text-utils/hexsyntax.c +++ b/text-utils/hexsyntax.c @@ -31,11 +31,16 @@ * SUCH DAMAGE. */ + /* 1999-02-22 Arkadiusz Miśkiewicz <misiek@misiek.eu.org> + * - added Native Language Support + */ + #include <sys/types.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include "hexdump.h" +#include "nls.h" off_t skip; /* bytes to skip */ @@ -72,7 +77,7 @@ void newsyntax(int argc, char ***argvp) case 'n': if ((length = atoi(optarg)) < 0) { (void)fprintf(stderr, - "hexdump: bad length value.\n"); + _("hexdump: bad length value.\n")); exit(1); } break; @@ -83,7 +88,7 @@ void newsyntax(int argc, char ***argvp) case 's': if ((skip = strtol(optarg, &p, 0)) < 0) { (void)fprintf(stderr, - "hexdump: bad skip value.\n"); + _("hexdump: bad skip value.\n")); exit(1); } switch(*p) { @@ -121,6 +126,6 @@ void newsyntax(int argc, char ***argvp) void usage() { (void)fprintf(stderr, -"hexdump: [-bcdovx] [-e fmt] [-f fmt_file] [-n length] [-s skip] [file ...]\n"); +_("hexdump: [-bcdovx] [-e fmt] [-f fmt_file] [-n length] [-s skip] [file ...]\n")); exit(1); } diff --git a/text-utils/more.c b/text-utils/more.c index 24045472d..4c2a179b6 100644 --- a/text-utils/more.c +++ b/text-utils/more.c @@ -26,12 +26,22 @@ ** on linux/axp. ** modified by Kars de Jong <jongk@cs.utwente.nl> to use terminfo instead ** of termcap. + 1999-02-22 Arkadiusz Miśkiewicz <misiek@misiek.eu.org> + - added Native Language Support + 1999-03-19 Arnaldo Carvalho de Melo <acme@conectiva.com.br> + - more nls translatable strings + 1999-05-09 aeb - applied a RedHat patch (setjmp->sigsetjmp); without it + a second ^Z would fail. + 1999-05-09 aeb - undone Kars' work, so that more works without libcurses + (and hence can be in /bin with libcurses being in /usr/lib which may not + be mounted). However, when termcap is not present curses can still be used. */ #include <stdio.h> #include <string.h> #include <unistd.h> #include <stdlib.h> /* for alloca() */ +#include <stdarg.h> /* for va_start() etc */ #include <sys/param.h> #include <ctype.h> #include <signal.h> @@ -43,13 +53,8 @@ #include <sys/file.h> #include <sys/wait.h> #include <a.out.h> -#if NCH -#include <ncurses.h> -#else -#include <curses.h> -#endif -#include <term.h> #include <locale.h> +#include "nls.h" #define HELPFILE "/usr/lib/more.help" #define VI "/usr/bin/vi" @@ -72,7 +77,7 @@ void home(void); void error (char *mess); void do_shell (char *filename); int colon (char *filename, int cmd, int nlines); -int expand (char *outbuf, char *inbuf); +int expand (char **outbuf, char *inbuf); void argscan(char *s); void rdline (register FILE *f); void copy_file(register FILE *f); @@ -132,7 +137,7 @@ int nfiles; /* Number of files left to process */ char *shell; /* The name of the shell to use */ int shellp; /* A previous shell command exists */ char ch; -jmp_buf restore; +sigjmp_buf restore; char Line[LINSIZ]; /* Line buffer */ int Lpp = 24; /* lines per page */ char *Clear; /* clear screen */ @@ -156,7 +161,90 @@ static int magic(); struct { long chrctr, line; } context, screen_start; -/* extern */ char PC; /* pad character */ +extern char PC; /* pad character */ + +#ifndef HAVE_termcap +#define USE_CURSES +#endif + +#ifdef USE_CURSES + +#if NCH +#include <ncurses.h> +#else +#include <curses.h> +#endif +#include <term.h> /* include after <curses.h> */ + +void +my_putstring(char *s) { + putp(s); +} + +void +my_setupterm(const char *term, int fildes, int *errret) { + setupterm(term, fildes, errret); +} + +int +my_tgetnum(char *s, char *ss) { + return tigetnum(ss); +} + +int +my_tgetflag(char *s, char *ss) { + return tigetflag(ss); +} + +char * +my_tgetstr(char *s, char *ss) { + return tigetstr(ss); +} + +char * +my_tgoto(const char *cap, int col, int row) { + return tparm(cap, col, row); +} + +#else /* no CURSES */ +#include <termcap.h> + +char termbuffer[4096]; +char tcbuffer[4096]; +char *strbuf = termbuffer; + +void +my_putstring(char *s) { + tputs (s, 1, putchar); +} + +void +my_setupterm(const char *term, int fildes, int *errret) { + *errret = tgetent(tcbuffer, term); +} + +int +my_tgetnum(char *s, char *ss) { + return tgetnum(s); +} + +int +my_tgetflag(char *s, char *ss) { + return tgetflag(s); +} + +char * +my_tgetstr(char *s, char *ss) { + return tgetstr(s, &strbuf); +} + +char * +my_tgoto(const char *cap, int col, int row) { + return tgoto(cap, col, row); +} + + +#endif /* USE_CURSES */ void idummy(int *kk) {} @@ -178,6 +266,10 @@ int main(int argc, char **argv) { char initbuf[80]; FILE *checkf(); + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + /* avoid gcc complaints about register variables that may be clobbered by a longjmp, by forcing our variables here to be non-register */ @@ -231,12 +323,10 @@ int main(int argc, char **argv) { if (nfiles > 1) prnames++; if (!no_intty && nfiles == 0) { - char *rindex(); - - p = rindex(argv[0], '/'); - fputs("usage: ",stderr); - fputs(p ? p + 1 : argv[0],stderr); - fputs(" [-dfln] [+linenum | +/pattern] name1 name2 ...\n",stderr); + p = strrchr(argv[0], '/'); + fprintf(stderr, + _("usage: %s [-dfln] [+linenum | +/pattern] name1 name2 ...\n"), + p ? p + 1 : argv[0]); exit(1); } else @@ -287,7 +377,7 @@ int main(int argc, char **argv) { if ((f = checkf (fnames[fnum], &clearit)) != NULL) { context.line = context.chrctr = 0; Currline = 0; - if (firstf) setjmp (restore); + if (firstf) sigsetjmp (restore, 1); if (firstf) { firstf = 0; if (srchopt) { @@ -299,7 +389,7 @@ int main(int argc, char **argv) { skiplns (initline, f); } else if (fnum < nfiles && !no_tty) { - setjmp (restore); + sigsetjmp (restore, 1); left = command (fnames[fnum], f); } if (left != 0) { @@ -333,7 +423,7 @@ int main(int argc, char **argv) { within = 0; } } - setjmp (restore); + sigsetjmp (restore, 1); fflush(stdout); fclose(f); screen_start.line = screen_start.chrctr = 0L; @@ -410,7 +500,7 @@ checkf (fs, clearfirst) return((FILE *)NULL); } if ((stbuf.st_mode & S_IFMT) == S_IFDIR) { - xprintf("\n*** %s: directory ***\n\n", fs); + xprintf(_("\n*** %s: directory ***\n\n"), fs); return((FILE *)NULL); } if ((f = Fopen(fs, "r")) == NULL) { @@ -449,7 +539,7 @@ magic(f, fs) case 0411: case 0177545: case 0x457f: /* simple ELF detection */ - xprintf("\n******** %s: Not a text file ********\n\n", fs); + xprintf(_("\n******** %s: Not a text file ********\n\n"), fs); (void)fclose(f); return(1); } @@ -504,7 +594,7 @@ void screen (register FILE *f, register int num_lines) num_lines--; } if (pstate) { - putp (ULexit); + my_putstring (ULexit); pstate = 0; } fflush(stdout); @@ -518,7 +608,7 @@ void screen (register FILE *f, register int num_lines) if (Pause && clreol) clreos (); Ungetc (c, f); - setjmp (restore); + sigsetjmp (restore, 1); Pause = 0; startup = 0; if ((num_lines = command (NULL, f)) == 0) return; @@ -547,13 +637,13 @@ void onquit() putchar ('\n'); if (!startup) { signal(SIGQUIT, onquit); - longjmp (restore, 1); + siglongjmp (restore, 1); } else Pause++; } else if (!dum_opt && notell) { - errwrite("[Use q or Q to quit]"); + errwrite(_("[Use q or Q to quit]")); promptlen += 20; notell = 0; } @@ -734,23 +824,23 @@ char *filename; if (!hard) { promptlen = 8; if (Senter && Sexit) { - putp (Senter); + my_putstring (Senter); promptlen += (2 * soglitch); } if (clreol) cleareol (); - pr("--More--"); + pr(_("--More--")); if (filename != NULL) { - promptlen += xprintf ("(Next file: %s)", filename); + promptlen += xprintf (_("(Next file: %s)"), filename); } else if (!no_intty) { promptlen += xprintf ("(%d%%)", (int)((file_pos * 100) / file_size)); } if (dum_opt) { - promptlen += pr("[Press space to continue, 'q' to quit.]"); + promptlen += pr(_("[Press space to continue, 'q' to quit.]")); } if (Senter && Sexit) - putp (Sexit); + my_putstring (Sexit); if (clreol) clreos (); fflush(stdout); @@ -797,7 +887,7 @@ int get_line(register FILE *f, int *length) if (!hardtabs || (column < promptlen && !hard)) { if (hardtabs && eraseln && !dumb) { column = 1 + (column | 7); - putp (eraseln); + my_putstring (eraseln); promptlen = 0; } else { @@ -866,7 +956,7 @@ void erasep (register int col) if (col == 0) putchar ('\r'); if (!dumb && eraseln) - putp (eraseln); + my_putstring (eraseln); else for (col = promptlen - col; col > 0; col--) putchar (' '); @@ -890,12 +980,12 @@ void kill_line () */ void cleareol() { - putp(eraseln); + my_putstring(eraseln); } void clreos() { - putp(EodClr); + my_putstring(EodClr); } /* @@ -939,13 +1029,13 @@ void prbuf (register char *s, register int n) if (c == ' ' && state == 0 && ulglitch && wouldul(s, n-1)) state = 1; else - putp(state ? ULenter : ULexit); + my_putstring(state ? ULenter : ULexit); } if (c != ' ' || pstate == 0 || state != 0 || ulglitch == 0) putchar(c); if (state && *chUL) { pr(chBS); - putp(chUL); + my_putstring(chUL); } pstate = state; } @@ -958,7 +1048,7 @@ void doclear() { if (Clear && !hard) { - putp(Clear); + my_putstring(Clear); /* Put out carriage return so that system doesn't ** get confused by escape sequences when expanding tabs @@ -974,12 +1064,12 @@ doclear() void home() { - putp(Home); + my_putstring(Home); } static int lastcmd, lastarg, lastp; static int lastcolon; -char shell_line[132]; +char shell_line[1000]; /* ** Read a command and do it. A command consists of an optional integer @@ -1017,7 +1107,7 @@ int command (char *filename, register FILE *f) } lastcmd = comchar; lastarg = nlines; - if (comchar == otty.c_cc[VERASE]) { + if ((cc_t) comchar == otty.c_cc[VERASE]) { kill_line (); prompt (filename); continue; @@ -1045,7 +1135,7 @@ int command (char *filename, register FILE *f) xprintf ("\n"); if (clreol) cleareol (); - xprintf ("...back %d page", nlines); + xprintf (_("...back %d page"), nlines); if (nlines > 1) pr ("s\n"); else @@ -1091,7 +1181,7 @@ int command (char *filename, register FILE *f) xprintf ("\n"); if (clreol) cleareol (); - xprintf ("...skipping %d line", nlines); + xprintf (_("...skipping %d line"), nlines); if (nlines > 1) pr ("s\n"); else @@ -1132,7 +1222,7 @@ int command (char *filename, register FILE *f) case '\'': if (!no_intty) { kill_line (); - pr ("\n***Back***\n\n"); + pr (_("\n***Back***\n\n")); Fseek (f, context.chrctr); Currline = context.line; ret (dlines); @@ -1170,7 +1260,7 @@ int command (char *filename, register FILE *f) case '?': case 'h': if ((helpf = fopen (HELPFILE, "r")) == NULL) - error ("Can't open help file"); + error (_("Can't open help file")); if (noscroll) doclear (); copy_file (helpf); fclose (helpf); @@ -1190,12 +1280,12 @@ int command (char *filename, register FILE *f) if (dum_opt) { kill_line (); if (Senter && Sexit) { - putp (Senter); - promptlen = pr ("[Press 'h' for instructions.]") + (2 * soglitch); - putp (Sexit); + my_putstring (Senter); + promptlen = pr (_("[Press 'h' for instructions.]")) + (2 * soglitch); + my_putstring (Sexit); } else - promptlen = pr ("[Press 'h' for instructions.]"); + promptlen = pr (_("[Press 'h' for instructions.]")); fflush (stdout); } else @@ -1230,9 +1320,9 @@ int colon (char *filename, int cmd, int nlines) case 'f': kill_line (); if (!no_intty) - promptlen = xprintf ("\"%s\" line %d", fnames[fnum], Currline); + promptlen = xprintf (_("\"%s\" line %d"), fnames[fnum], Currline); else - promptlen = xprintf ("[Not a file] line %d", Currline); + promptlen = xprintf (_("[Not a file] line %d"), Currline); fflush (stdout); return (-1); case 'n': @@ -1282,7 +1372,7 @@ int number(char *cmd) ch = readch (); if (isdigit(ch)) i = i*10 + ch - '0'; - else if (ch == otty.c_cc[VKILL]) + else if ((cc_t) ch == otty.c_cc[VKILL]) i = 0; else { *cmd = ch; @@ -1294,7 +1384,9 @@ int number(char *cmd) void do_shell (char *filename) { - char cmdbuf[80]; + char cmdbuf[200]; + int rc; + char *expanded; kill_line (); pr ("!"); @@ -1304,7 +1396,20 @@ void do_shell (char *filename) pr (shell_line); else { ttyin (cmdbuf, sizeof(cmdbuf)-2, '!'); - if (expand (shell_line, cmdbuf)) { + expanded = 0; + rc = expand (&expanded, cmdbuf); + if (expanded) { + if (strlen(expanded) < sizeof(shell_line)) + strcpy(shell_line, expanded); + else + rc = -1; + free(expanded); + } + if (rc < 0) { + errwrite(_(" Overflow\n")); + prompt (filename); + return; + } else if (rc > 0) { kill_line (); promptlen = xprintf ("!%s", shell_line); } @@ -1348,7 +1453,7 @@ void search(char buf[], FILE *file, register int n) pr ("\n"); if (clreol) cleareol (); - pr("...skipping\n"); + pr(_("...skipping\n")); } if (!no_intty) { Currline -= (lncount >= 3 ? 3 : lncount); @@ -1378,7 +1483,7 @@ void search(char buf[], FILE *file, register int n) break; } } else if (rv == -1) - error ("Regular expression botch"); + error (_("Regular expression botch")); } if (feof (file)) { if (!no_intty) { @@ -1390,10 +1495,10 @@ void search(char buf[], FILE *file, register int n) Fseek (file, startline); } else { - pr ("\nPattern not found\n"); + pr (_("\nPattern not found\n")); end_it (); } - error ("Pattern not found"); + error (_("Pattern not found")); } } @@ -1418,14 +1523,13 @@ void execute (char * filename, char * cmd, ...) } va_start(argp, cmd); - arg = va_arg(argp, char *); argcount = 0; while (arg) { argcount++; arg = va_arg(argp, char *); } - va_end(argp); /* balance {}'s for some UNIX's */ + va_end(argp); args = alloca(sizeof(char *) * (argcount + 1)); args[argcount] = NULL; @@ -1438,10 +1542,10 @@ void execute (char * filename, char * cmd, ...) argcount++; arg = va_arg(argp, char *); } - va_end(argp); /* balance {}'s for some UNIX's */ + va_end(argp); execv (cmd, args); - errwrite("exec failed\n"); + errwrite(_("exec failed\n")); exit (1); } if (id > 0) { @@ -1455,7 +1559,7 @@ void execute (char * filename, char * cmd, ...) if (catch_susp) signal(SIGTSTP, onsusp); } else - errwrite("can't fork\n"); + errwrite(_("can't fork\n")); set_tty (); pr ("------------------------\n"); prompt (filename); @@ -1494,12 +1598,12 @@ void skipf (register int nskip) fnum += nskip; if (fnum < 0) fnum = 0; - pr ("\n...Skipping "); + pr (_("\n...Skipping ")); pr ("\n"); if (clreol) cleareol (); - pr ("...Skipping "); - pr (nskip > 0 ? "to file " : "back to file "); + pr (_("...Skipping ")); + pr (nskip > 0 ? _("to file ") : _("back to file ")); pr (fnames[fnum]); pr ("\n"); if (clreol) @@ -1544,7 +1648,7 @@ retry: if ((term = getenv("TERM")) == 0) { dumb++; ul_opt = 0; } - setupterm(term, 1, &ret); + my_setupterm(term, 1, &ret); if (ret <= 0) { dumb++; ul_opt = 0; } @@ -1552,35 +1656,35 @@ retry: #ifdef TIOCGWINSZ if (ioctl(fileno(stdout), TIOCGWINSZ, &win) < 0) { #endif - Lpp = tigetnum("lines"); - Mcol = tigetnum("cols"); + Lpp = my_tgetnum("li","lines"); + Mcol = my_tgetnum("co","cols"); #ifdef TIOCGWINSZ } else { if ((Lpp = win.ws_row) == 0) - Lpp = tigetnum("lines"); + Lpp = my_tgetnum("li","lines"); if ((Mcol = win.ws_col) == 0) - Mcol = tigetnum("cols"); + Mcol = my_tgetnum("co","cols"); } #endif - if ((Lpp <= 0) || tigetflag("hc")) { + if ((Lpp <= 0) || my_tgetflag("hc","hc")) { hard++; /* Hard copy terminal */ Lpp = 24; } - if (tigetflag("xenl")) + if (my_tgetflag("xn","xenl")) eatnl++; /* Eat newline at last column + 1; dec, concept */ if (Mcol <= 0) Mcol = 80; if (tailequ (fnames[0], "page")) noscroll++; - Wrap = tigetflag("am"); - bad_so = tigetflag ("xhp"); - eraseln = tigetstr("el"); - Clear = tigetstr("clear"); - Senter = tigetstr("smso"); - Sexit = tigetstr("rmso"); - if ((soglitch = tigetnum("xmc")) < 0) + Wrap = my_tgetflag("am","am"); + bad_so = my_tgetflag ("xs","xhp"); + eraseln = my_tgetstr("ce","el"); + Clear = my_tgetstr("cl","clear"); + Senter = my_tgetstr("co","smso"); + Sexit = my_tgetstr("se","rmso"); + if ((soglitch = my_tgetnum("sg","xmc")) < 0) soglitch = 0; /* @@ -1591,12 +1695,12 @@ retry: * isn't available, settle for standout sequence. */ - if (tigetflag("ul") || tigetflag("os")) + if (my_tgetflag("ul","ul") || my_tgetflag("os","os")) ul_opt = 0; - if ((chUL = tigetstr("uc")) == NULL ) + if ((chUL = my_tgetstr("uc","uc")) == NULL ) chUL = ""; - if (((ULenter = tigetstr("smul")) == NULL || - (ULexit = tigetstr("rmul")) == NULL) && !*chUL) { + if (((ULenter = my_tgetstr("us","smul")) == NULL || + (ULexit = my_tgetstr("ue","rmul")) == NULL) && !*chUL) { if ((ULenter = Senter) == NULL || (ULexit = Sexit) == NULL) { ULenter = ""; ULexit = ""; @@ -1606,18 +1710,20 @@ retry: ulglitch = 0; } - if ((padstr = tigetstr("pad")) != NULL) + if ((padstr = my_tgetstr("pc","pad")) != NULL) PC = *padstr; - Home = tigetstr("home"); + Home = my_tgetstr("ho","home"); if (Home == 0 || *Home == '\0') { - if ((cursorm = tigetstr("cup")) != NULL) { - strcpy(cursorhome, (const char *)tparm(cursorm, 0, 0)); + if ((cursorm = my_tgetstr("cm","cup")) != NULL) { + const char *t = (const char *)my_tgoto(cursorm, 0, 0); + strncpy(cursorhome, t, sizeof(cursorhome)); + cursorhome[sizeof(cursorhome)-1] = 0; Home = cursorhome; } } - EodClr = tigetstr("ed"); - if ((chBS = tigetstr("cub1")) == NULL) + EodClr = my_tgetstr("cd","ed"); + if ((chBS = my_tgetstr("le","cub1")) == NULL) chBS = "\b"; } @@ -1676,7 +1782,7 @@ void ttyin (char buf[], register int nmax, char pchar) if (ch == '\\') { slash++; } - else if ((ch == otty.c_cc[VERASE]) && !slash) { + else if (((cc_t) ch == otty.c_cc[VERASE]) && !slash) { if (sptr > buf) { --promptlen; ERASEONECHAR @@ -1689,10 +1795,10 @@ void ttyin (char buf[], register int nmax, char pchar) } else { if (!eraseln) promptlen = maxlen; - longjmp (restore, 1); + siglongjmp (restore, 1); } } - else if ((ch == otty.c_cc[VKILL]) && !slash) { + else if (((cc_t) ch == otty.c_cc[VKILL]) && !slash) { if (hard) { show (ch); putchar ('\n'); @@ -1712,7 +1818,8 @@ void ttyin (char buf[], register int nmax, char pchar) fflush (stdout); continue; } - if (slash && (ch == otty.c_cc[VKILL] || ch == otty.c_cc[VERASE])) { + if (slash && ((cc_t) ch == otty.c_cc[VKILL] + || (cc_t) ch == otty.c_cc[VERASE])) { ERASEONECHAR --sptr; } @@ -1735,33 +1842,51 @@ void ttyin (char buf[], register int nmax, char pchar) *--sptr = '\0'; if (!eraseln) promptlen = maxlen; if (sptr - buf >= nmax - 1) - error ("Line too long"); + error (_("Line too long")); } -int expand (char *outbuf, char *inbuf) +/* return: 0 - unchanged, 1 - changed, -1 - overflow (unchanged) */ +int expand (char **outbuf, char *inbuf) { - register char *instr; - register char *outstr; - register char ch; - char temp[200]; + char *instr; + char *outstr; + char ch; + char *temp; int changed = 0; - + int tempsz, xtra, offset; + + xtra = strlen (fnames[fnum]) + strlen (shell_line) + 1; + tempsz = 200 + xtra; + temp = malloc(tempsz); + if (!temp) { + error (_("Out of memory")); + return -1; + } instr = inbuf; outstr = temp; - while ((ch = *instr++) != '\0') + while ((ch = *instr++) != '\0'){ + offset = outstr-temp; + if (tempsz-offset-1 < xtra) { + tempsz += 200 + xtra; + temp = realloc(temp, tempsz); + if (!temp) { + error (_("Out of memory")); + return -1; + } + outstr = temp + offset; + } switch (ch) { case '%': if (!no_intty) { strcpy (outstr, fnames[fnum]); outstr += strlen (fnames[fnum]); changed++; - } - else + } else *outstr++ = ch; break; case '!': if (!shellp) - error ("No previous command to substitute for"); + error (_("No previous command to substitute for")); strcpy (outstr, shell_line); outstr += strlen (shell_line); changed++; @@ -1774,8 +1899,9 @@ int expand (char *outbuf, char *inbuf) default: *outstr++ = ch; } + } *outstr++ = '\0'; - strcpy (outbuf, temp); + *outbuf = temp; return (changed); } @@ -1811,15 +1937,15 @@ void error (char *mess) kill_line (); promptlen += strlen (mess); if (Senter && Sexit) { - putp (Senter); + my_putstring (Senter); pr(mess); - putp (Sexit); + my_putstring (Sexit); } else pr (mess); fflush(stdout); errors++; - longjmp (restore, 1); + siglongjmp (restore, 1); } @@ -1891,5 +2017,5 @@ void onsusp () signal (SIGTSTP, onsusp); set_tty (); if (inwait) - longjmp (restore, 1); + siglongjmp (restore, 1); } diff --git a/text-utils/more.help.cs b/text-utils/more.help.cs new file mode 100644 index 000000000..1a69cb365 --- /dev/null +++ b/text-utils/more.help.cs @@ -0,0 +1,28 @@ + +Většině příkazů může jako argument předcházet celé číslo k. Implicitní hodnoty +jsou v hranatých závorkách. Hvězdička (*) znamená, že hodnota argumentu se +stane implicitní. +------------------------------------------------------------------------------- +<mezerník> Zobrazí dalších k řádků textu. [aktuální velikost + obrazovky] +z Zobrazí dalších k řádků textu. [aktuální velikost + obrazovky]* +<return> Zobrazí dalších k řádků textu. [1]* +d či ctrl-D Posun o k řádků [aktuální velikost posunu, po spuštění + 11]* +q či Q či <interrupt> Ukončení programu +s Posun vpřed o k řádků [1] +f Posun vpřed o k stran [1] +b či ctrl-B Posun vzad o k stran [1] +' Přeskočí na místo, kde bylo zahájeno předchozí hledání += Zobrazí číslo aktuálního řádku +/<regulární výraz> Hledá ktý výskyt regulárního výrazu [1] +n Hledá ktý výrazu posledního regulárního výrazu [1] +!<příkaz> či :!<příkaz> Spustí <příkaz> v podshellu +v Spustí /usr/bin/vi na aktuálním řádku +ctrl-L Překreslí obrazovku +:n Přeskočí na ktý následující soubor [1] +:p Přeskočí na ktý předcházející soubor [1] +:f Vypíše jméno aktuálního souboru a číslo aktuálního řádku +. Zopakuje předcházející příkaz +------------------------------------------------------------------------------- diff --git a/text-utils/odsyntax.c b/text-utils/odsyntax.c index cc543c33c..c22e71d01 100644 --- a/text-utils/odsyntax.c +++ b/text-utils/odsyntax.c @@ -31,12 +31,17 @@ * SUCH DAMAGE. */ + /* 1999-02-22 Arkadiusz Miśkiewicz <misiek@misiek.eu.org> + * - added Native Language Support + */ + #include <sys/types.h> #include <stdlib.h> #include <stdio.h> #include <ctype.h> /* for isdigit() */ #include <unistd.h> /* for getopt() */ #include "hexdump.h" +#include "nls.h" static void odoffset(int, char ***); @@ -125,11 +130,11 @@ oldsyntax(int argc, char ***argvp) case '?': default: (void)fprintf(stderr, - "od: od(1) has been deprecated for hexdump(1).\n"); + _("od: od(1) has been deprecated for hexdump(1).\n")); if (ch != '?') (void)fprintf(stderr, -"od: hexdump(1) compatibility doesn't support the -%c option%s\n", - ch, ch == 's' ? "; see strings(1)." : "."); +_("od: hexdump(1) compatibility doesn't support the -%c option%s\n"), + ch, ch == 's' ? _("; see strings(1).") : "."); usage(); } diff --git a/text-utils/parse.c b/text-utils/parse.c index ececd1316..1102e975d 100644 --- a/text-utils/parse.c +++ b/text-utils/parse.c @@ -31,6 +31,10 @@ * SUCH DAMAGE. */ + /* 1999-02-22 Arkadiusz Miśkiewicz <misiek@misiek.eu.org> + * - added Native Language Support + */ + #include <sys/types.h> #include <sys/file.h> #include <stdio.h> @@ -38,6 +42,7 @@ #include <ctype.h> #include <string.h> #include "hexdump.h" +#include "nls.h" static void escape(register char *p1); static void badcnt(char *s); @@ -55,12 +60,12 @@ void addfile(char *name) char buf[2048 + 1]; if (!(fp = fopen(name, "r"))) { - (void)fprintf(stderr, "hexdump: can't read %s.\n", name); + (void)fprintf(stderr, _("hexdump: can't read %s.\n"), name); exit(1); } while (fgets(buf, sizeof(buf), fp)) { if (!(p = index(buf, '\n'))) { - (void)fprintf(stderr, "hexdump: line too long.\n"); + (void)fprintf(stderr, _("hexdump: line too long.\n")); while ((ch = getchar()) != '\n' && ch != EOF); continue; } @@ -398,7 +403,7 @@ sw2: switch(fu->bcnt) { /* only one conversion character if byte count */ if (!(pr->flags&F_ADDRESS) && fu->bcnt && nconv++) { (void)fprintf(stderr, - "hexdump: byte count with multiple conversion characters.\n"); + _("hexdump: byte count with multiple conversion characters.\n")); exit(1); } } @@ -482,25 +487,25 @@ static void escape(register char *p1) static void badcnt(char *s) { (void)fprintf(stderr, - "hexdump: bad byte count for conversion character %s.\n", s); + _("hexdump: bad byte count for conversion character %s.\n"), s); exit(1); } static void badsfmt() { (void)fprintf(stderr, - "hexdump: %%s requires a precision or a byte count.\n"); + _("hexdump: %%s requires a precision or a byte count.\n")); exit(1); } static void badfmt(char *fmt) { - (void)fprintf(stderr, "hexdump: bad format {%s}\n", fmt); + (void)fprintf(stderr, _("hexdump: bad format {%s}\n"), fmt); exit(1); } static void badconv(char *ch) { - (void)fprintf(stderr, "hexdump: bad conversion character %%%s.\n", ch); + (void)fprintf(stderr, _("hexdump: bad conversion character %%%s.\n"), ch); exit(1); } diff --git a/text-utils/rev.c b/text-utils/rev.c index 5c3a8406d..dbc25cd80 100644 --- a/text-utils/rev.c +++ b/text-utils/rev.c @@ -37,6 +37,9 @@ * last line that has no newline correctly. * 3-Jun-1998: Patched by Nicolai Langfeldt to work better on Linux: * Handle any-length-lines. Code copied from util-linux' setpwnam.c + * 1999-02-22 Arkadiusz Miśkiewicz <misiek@misiek.eu.org> + * - added Native Language Support + * */ #include <sys/types.h> @@ -45,6 +48,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include "nls.h" void usage __P((void)); void warn __P((const char *, ...)); @@ -61,6 +65,10 @@ main(argc, argv) FILE *fp; int ch, rval; + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + while ((ch = getopt(argc, argv, "")) != EOF) switch(ch) { case '?': @@ -98,7 +106,7 @@ main(argc, argv) p = realloc(p, buflen); if (p == NULL) { - fprintf(stderr,"Unable to allocate bufferspace\n"); + fprintf(stderr,_("Unable to allocate bufferspace\n")); exit(1); } @@ -156,6 +164,6 @@ warn(fmt, va_alist) void usage() { - (void)fprintf(stderr, "usage: rev [file ...]\n"); + (void)fprintf(stderr, _("usage: rev [file ...]\n")); exit(1); } diff --git a/text-utils/ul.c b/text-utils/ul.c index 8da3b3f7c..a99de9d88 100644 --- a/text-utils/ul.c +++ b/text-utils/ul.c @@ -34,14 +34,18 @@ /* ** modified by Kars de Jong <jongk@cs.utwente.nl> to use terminfo instead ** of termcap. + 1999-02-22 Arkadiusz Miśkiewicz <misiek@misiek.eu.org> + - added Native Language Support + */ #include <stdio.h> #include <unistd.h> /* for getopt(), isatty() */ -#include <string.h> /* for bzero() */ +#include <string.h> /* for bzero(), strcpy() */ #include <term.h> /* for setupterm() */ #include <stdlib.h> /* for getenv() */ #include <limits.h> /* for INT_MAX */ +#include "nls.h" void filter(FILE *f); void flushln(void); @@ -98,6 +102,10 @@ int main(int argc, char **argv) char *termtype; FILE *f; + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + termtype = getenv("TERM"); if (termtype == NULL || (argv[0][0] == 'c' && !isatty(1))) termtype = "lpr"; @@ -114,7 +122,7 @@ int main(int argc, char **argv) default: fprintf(stderr, - "usage: %s [ -i ] [ -tTerm ] file...\n", + _("usage: %s [ -i ] [ -tTerm ] file...\n"), argv[0]); exit(1); } @@ -125,7 +133,7 @@ int main(int argc, char **argv) break; default: - fprintf(stderr,"trouble reading terminfo"); + fprintf(stderr,_("trouble reading terminfo")); /* fall through to ... */ case 0: @@ -212,7 +220,7 @@ void filter(FILE *f) default: fprintf(stderr, - "Unknown escape sequence in input: %o, %o\n", + _("Unknown escape sequence in input: %o, %o\n"), IESC, c); exit(1); } @@ -361,7 +369,7 @@ void initbuf() obuflen = INITBUF; obuf = malloc(sizeof(struct CHAR) * obuflen); if (obuf == NULL) { - fprintf(stderr, "Unable to allocate buffer.\n"); + fprintf(stderr, _("Unable to allocate buffer.\n")); exit(1); } } @@ -518,7 +526,7 @@ void setcol(int newcol) /* Paranoid check for obuflen == INT_MAX. */ if (obuflen == INT_MAX) { fprintf(stderr, - "Input line too long.\n"); + _("Input line too long.\n")); exit(1); } @@ -531,7 +539,7 @@ void setcol(int newcol) obuf = realloc(obuf, sizeof(struct CHAR) * obuflen); if (obuf == NULL) { fprintf(stderr, - "Out of memory when growing buffer.\n"); + _("Out of memory when growing buffer.\n")); exit(1); } } |