Diferencias
Muestra las diferencias entre dos versiones de la página.
| Próxima revisión | Revisión previa | ||
| ecce.c [2022/11/19 00:41] – creado peron | ecce.c [2026/04/21 16:06] (actual) – editor externo 127.0.0.1 | ||
|---|---|---|---|
| Línea 1: | Línea 1: | ||
| - | <code c> | + | <file c ecce.c> |
| - | /* This file is http:// | + | |
| - | It is written in reasonably portable C and should | + | |
| - | be easy to compile with any C compiler, eg on Linux: | + | |
| - | cc -o ecce -DWANT_UTF8 | + | |
| - | + | ||
| - | You may need to do: export LC_ALL=en_US.UTF-8 | + | |
| - | + | ||
| - | | + | |
| - | a couple of places where linux filenames are used - | + | |
| - | you may need to make some small changes if compiling | + | |
| - | for Windows or other non-unix systems. | + | |
| - | in the source below. | + | |
| - | to gtoal@gtoal.com please. | + | |
| - | even a linux system is single-user. | + | |
| - | | + | |
| - | | + | |
| - | bad actors. | + | |
| - | + | ||
| - | | + | |
| - | of ecce in Emacs, by making a version of the " | + | |
| - | | + | |
| - | to pass the ecce command as a parameter while avoiding | + | |
| - | | + | |
| - | + | ||
| - | + | ||
| - | *SYS* | + | |
| - | Add this to your ~/.emacs file (or some equivalent for Windows): | + | |
| - | + | ||
| - | ;; hex encoding needed below. Came from https:// | + | |
| - | (eval-when-compile | + | |
| - | (defmacro num-to-hex-char (num) | + | |
| - | `(aref " | + | |
| - | ) | + | |
| - | + | ||
| - | (defun encode-hex-string (string) | + | |
| - | " | + | |
| - | (let* ((len (length string)) | + | |
| - | (dst (make-string (* len 2) 0)) | + | |
| - | (idx 0)(pos 0)) | + | |
| - | (while (< pos len) | + | |
| - | (aset dst idx (num-to-hex-char (/ (aref string pos) 16))) | + | |
| - | (setq idx (1+ idx)) | + | |
| - | (aset dst idx (num-to-hex-char (% (aref string pos) 16))) | + | |
| - | (setq idx (1+ idx) pos (1+ pos))) | + | |
| - | dst)) | + | |
| - | + | ||
| - | ;; Embedded ECCE support | + | |
| - | + | ||
| - | (defun e (ecce_command) | + | |
| - | (interactive "sEcce> ") | + | |
| - | (let (oldpoint (point)) | + | |
| - | (setq oldpoint (point)) | + | |
| - | (call-process-region (point-min) (point-max) | + | |
| - | "/ | + | |
| - | t t nil | + | |
| - | " | + | |
| - | | + | |
| - | | + | |
| - | (format " | + | |
| - | ) | + | |
| - | ) " 2> ~/ | + | |
| - | ) | + | |
| - | (goto-char (point-min)) | + | |
| - | (search-forward (format " | + | |
| - | (replace-match "" | + | |
| - | ) | + | |
| - | ) | + | |
| - | + | ||
| - | (global-set-key " | + | |
| - | + | ||
| - | */ | + | |
| #define VERSION " | #define VERSION " | ||
| | | ||
| Línea 103: | Línea 31: | ||
| /* */ | /* */ | ||
| /* */ | /* */ | ||
| - | /* | + | /* |
| - | /* retired. | + | /* retirado. |
| - | /* Toal, of the Edinburgh Computer History | + | /* Toal, del Proyecto de Historia del Cómputo |
| - | /* Project. | + | /* de Edimburgo. */ |
| /* */ | /* */ | ||
| - | /* This source is released into the public domain | + | /* Este código fuente fue lanzado al dominio |
| - | /* by the author, without restriction. | + | /* público por su autor, sin restricciones |
| /* */ | /* */ | ||
| /* (c) Graham Toal, 1984. (Original BCPL version, */ | /* (c) Graham Toal, 1984. (Original BCPL version, */ | ||
| Línea 525: | Línea 453: | ||
| if ((' | if ((' | ||
| if ((' | if ((' | ||
| - | fprintf(stderr, | + | fprintf(stderr, |
| exit(1); | exit(1); | ||
| } | } | ||
| Línea 532: | Línea 460: | ||
| static char commandline[Max_parameter], | static char commandline[Max_parameter], | ||
| if (strlen(hex)/ | if (strlen(hex)/ | ||
| - | fprintf(stderr, | + | fprintf(stderr, |
| exit(1); | exit(1); | ||
| } | } | ||
| Línea 541: | Línea 469: | ||
| c1 = h(*f++); | c1 = h(*f++); | ||
| if (*f == ' | if (*f == ' | ||
| - | fprintf(stderr, | + | fprintf(stderr, |
| exit(1); | exit(1); | ||
| } | } | ||
| Línea 587: | Línea 515: | ||
| int offset = 1; | int offset = 1; | ||
| if (argv[argno][1] == ' | if (argv[argno][1] == ' | ||
| - | if (strcmp(argv[argno]+offset, | + | if (strcmp(argv[argno]+offset, |
| parameter[F] = argv[argno+1]; | parameter[F] = argv[argno+1]; | ||
| - | } else if (strcmp(argv[argno]+offset, | + | } else if (strcmp(argv[argno]+offset, |
| parameter[T] = argv[argno+1]; | parameter[T] = argv[argno+1]; | ||
| } else if (strcmp(argv[argno]+offset, | } else if (strcmp(argv[argno]+offset, | ||
| Línea 595: | Línea 523: | ||
| } else if (strcmp(argv[argno]+offset, | } else if (strcmp(argv[argno]+offset, | ||
| if (parameter[C] != NULL) { | if (parameter[C] != NULL) { | ||
| - | fprintf(stderr, | + | fprintf(stderr, |
| exit(1); | exit(1); | ||
| } | } | ||
| Línea 611: | Línea 539: | ||
| buffer_size = strtoul(buf_size_str, | buffer_size = strtoul(buf_size_str, | ||
| if (errno != 0) { | if (errno != 0) { | ||
| - | fprintf(stderr, | + | fprintf(stderr, |
| exit(1); | exit(1); | ||
| } | } | ||
| Línea 622: | Línea 550: | ||
| } else { | } else { | ||
| fprintf(stderr, | fprintf(stderr, | ||
| - | " | + | " |
| ProgName, endptr, buffer_size, | ProgName, endptr, buffer_size, | ||
| exit(1); | exit(1); | ||
| Línea 629: | Línea 557: | ||
| } else { | } else { | ||
| fprintf (stderr, | fprintf (stderr, | ||
| - | " | + | " |
| ProgName, argv[argno]); | ProgName, argv[argno]); | ||
| exit(1); | exit(1); | ||
| Línea 645: | Línea 573: | ||
| if (parameter[F] == NULL) { | if (parameter[F] == NULL) { | ||
| fprintf (stderr, | fprintf (stderr, | ||
| - | " | + | " |
| ProgName); | ProgName); | ||
| exit (30); | exit (30); | ||
| Línea 658: | Línea 586: | ||
| /* If the input file is stdin, you cannot read commands from stdin as well. */ | /* If the input file is stdin, you cannot read commands from stdin as well. */ | ||
| if (commandp == NULL) { | if (commandp == NULL) { | ||
| - | fprintf(stderr, | + | fprintf(stderr, |
| } | } | ||
| main_in = stdin; | main_in = stdin; | ||
| Línea 665: | Línea 593: | ||
| tty_in = fopen("/ | tty_in = fopen("/ | ||
| if (tty_in) { | if (tty_in) { | ||
| - | fprintf(stderr, | + | fprintf(stderr, |
| } else { | } else { | ||
| tty_in = fopen(" | tty_in = fopen(" | ||
| if (tty_in) { | if (tty_in) { | ||
| - | | + | |
| } else { | } else { | ||
| | | ||
| if (tty_in == NULL) tty_in = fopen(" | if (tty_in == NULL) tty_in = fopen(" | ||
| - | | + | |
| if (tty_in == NULL) tty_in = stdin; /* It'll be EOF by the time it is used */ | if (tty_in == NULL) tty_in = stdin; /* It'll be EOF by the time it is used */ | ||
| } | } | ||
| Línea 682: | Línea 610: | ||
| if (main_in == NULL) { | if (main_in == NULL) { | ||
| - | fprintf (stderr, "File \" | + | fprintf (stderr, "Fichero |
| exit (30); | exit (30); | ||
| } | } | ||
| Línea 691: | Línea 619: | ||
| log_out = fopen (parameter[L], | log_out = fopen (parameter[L], | ||
| if (log_out == NULL) { | if (log_out == NULL) { | ||
| - | | + | |
| ProgName, parameter[L]); | ProgName, parameter[L]); | ||
| } | } | ||
| Línea 745: | Línea 673: | ||
| link == NULL || text == NULL || num == NULL || lim == NULL || | link == NULL || text == NULL || num == NULL || lim == NULL || | ||
| com_prompt == NULL) { | com_prompt == NULL) { | ||
| - | fprintf (stderr, "Unable to claim buffer space\n"); | + | fprintf (stderr, "Incapaz de referir espacio de almacenamiento\n"); |
| free_buffers(); | free_buffers(); | ||
| exit (40); | exit (40); | ||
| } | } | ||
| - | | + | |
| Línea 900: | Línea 828: | ||
| ok = TRUE; | ok = TRUE; | ||
| if (!isalpha(Command_sym)) { | if (!isalpha(Command_sym)) { | ||
| - | (void) fail_with ("letter for", ' | + | (void) fail_with ("letra para", ' |
| return; | return; | ||
| } | } | ||
| Línea 935: | Línea 863: | ||
| | | ||
| #endif | #endif | ||
| - | | + | |
| | | ||
| Línea 941: | Línea 869: | ||
| if ((strcmp(parameter[parameter[T] == NULL ? F : T], " | if ((strcmp(parameter[parameter[T] == NULL ? F : T], " | ||
| ((parameter[T] != NULL) && (strcmp(parameter[T], | ((parameter[T] != NULL) && (strcmp(parameter[T], | ||
| - | | + | |
| | | ||
| } | } | ||
| Línea 964: | Línea 892: | ||
| (void)strcpy (com_prompt, | (void)strcpy (com_prompt, | ||
| if (sec_out == NULL) { | if (sec_out == NULL) { | ||
| - | | + | |
| | | ||
| } | } | ||
| Línea 996: | Línea 924: | ||
| if (main_out == NULL) { | if (main_out == NULL) { | ||
| | | ||
| - | " | + | " |
| | | ||
| } | } | ||
| - | fprintf (tty_out, " | + | fprintf (tty_out, " |
| } else { | } else { | ||
| if ((strcmp(parameter[inoutlog], | if ((strcmp(parameter[inoutlog], | ||
| Línea 1007: | Línea 935: | ||
| if (main_out == NULL) { | if (main_out == NULL) { | ||
| | | ||
| - | "Can't create | + | "No puedo crear \" |
| parameter[inoutlog], | parameter[inoutlog], | ||
| | | ||
| if (main_out == NULL) { | if (main_out == NULL) { | ||
| - | | + | |
| | | ||
| } | } | ||
| Línea 1017: | Línea 945: | ||
| if (inoutlog == T) { | if (inoutlog == T) { | ||
| fprintf (tty_out, | fprintf (tty_out, | ||
| - | " | + | " |
| } else { | } else { | ||
| - | fprintf (tty_out, "Ecce %s completing.\n", parameter[F]); | + | fprintf (tty_out, "Ecce %s completando.\n", parameter[F]); |
| } | } | ||
| } | } | ||
| Línea 1048: | Línea 976: | ||
| fclose (log_out); | fclose (log_out); | ||
| } | } | ||
| - | | + | |
| | | ||
| exit (60); | exit (60); | ||
| Línea 1091: | Línea 1019: | ||
| (void)strcpy (com_prompt, | (void)strcpy (com_prompt, | ||
| if (sec_out == NULL) { | if (sec_out == NULL) { | ||
| - | | + | |
| | | ||
| } | } | ||
| Línea 1124: | Línea 1052: | ||
| if (sec_in == NULL) { | if (sec_in == NULL) { | ||
| if (file_wanted) { | if (file_wanted) { | ||
| - | (void) fail_with ("Cannot open file", ' '); | + | (void) fail_with ("No puede abrir fichero", ' '); |
| } else { | } else { | ||
| - | (void) fail_with ("Unknown context", sec_no); | + | (void) fail_with ("Context desconocido", sec_no); |
| } | } | ||
| | | ||
| Línea 1147: | Línea 1075: | ||
| *P++ = sym; | *P++ = sym; | ||
| if (P == fend) { | if (P == fend) { | ||
| - | (void) fail_with (" | + | (void) fail_with (" |
| fclose (sec_in); | fclose (sec_in); | ||
| return; | return; | ||
| Línea 1160: | Línea 1088: | ||
| default: | default: | ||
| - | | + | |
| } | } | ||
| do { read_sym(); } while (sym_type(sym) != sym_type(';' | do { read_sym(); } while (sym_type(sym) != sym_type(';' | ||
| Línea 1195: | Línea 1123: | ||
| for (;;) { | for (;;) { | ||
| if (i == noted) { | if (i == noted) { | ||
| - | | + | |
| if (i == lbeg) fputc (' | if (i == lbeg) fputc (' | ||
| } | } | ||
| Línea 1216: | Línea 1144: | ||
| } else fputc (sym, tty_out); | } else fputc (sym, tty_out); | ||
| } | } | ||
| - | if (i == fend) fprintf (tty_out, " | + | if (i == fend) fprintf (tty_out, " |
| fputc (' | fputc (' | ||
| if (repeat_count == 1L) return; | if (repeat_count == 1L) return; | ||
| Línea 1562: | Línea 1490: | ||
| default: | default: | ||
| - | | + | |
| | | ||
| } | } | ||
| Línea 1597: | Línea 1525: | ||
| if ((sym_type(sym) & delim) == 0) { | if ((sym_type(sym) & delim) == 0) { | ||
| pending_sym = sym; | pending_sym = sym; | ||
| - | (void) fail_with ("Text for", command); | + | (void) fail_with ("Texto para", command); |
| return; | return; | ||
| } | } | ||
| Línea 1669: | Línea 1597: | ||
| for (;;) { /* on items */ | for (;;) { /* on items */ | ||
| if ((type & err) != 0) { | if ((type & err) != 0) { | ||
| - | | + | |
| } | } | ||
| if ((type & delim) != 0) { | if ((type & delim) != 0) { | ||
| - | | + | |
| } | } | ||
| if ((type & numb) != 0) { | if ((type & numb) != 0) { | ||
| - | | + | |
| } | } | ||
| limit = 0L; | limit = 0L; | ||
| Línea 1695: | Línea 1623: | ||
| | | ||
| if (pointer >= 0) { | if (pointer >= 0) { | ||
| - | return (fail_with ("Missing", ' | + | return (fail_with ("Faltante", ' |
| } | } | ||
| | | ||
| Línea 1722: | Línea 1650: | ||
| | | ||
| if (pointer < 0) { | if (pointer < 0) { | ||
| - | return (fail_with ("Missing", ' | + | return (fail_with ("Faltante", ' |
| } | } | ||
| | | ||
| Línea 1743: | Línea 1671: | ||
| *p++ = sym; | *p++ = sym; | ||
| if (p == fend) { | if (p == fend) { | ||
| - | | + | |
| | | ||
| } | } | ||
| Línea 1751: | Línea 1679: | ||
| #ifdef WANT_UTF8 | #ifdef WANT_UTF8 | ||
| if (errno == EILSEQ) { | if (errno == EILSEQ) { | ||
| - | fprintf(stderr, | + | fprintf(stderr, |
| exit(1); | exit(1); | ||
| } | } | ||
| Línea 1830: | Línea 1758: | ||
| } | } | ||
| if (com[this_unit] == 0) {/* 0 denotes end of command-line. */ | if (com[this_unit] == 0) {/* 0 denotes end of command-line. */ | ||
| - | | + | |
| } | } | ||
| | | ||
| Línea 2047: | Línea 1975: | ||
| | | ||
| } | } | ||
| - | </code> | + | </file> |
