Herramientas de usuario

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Próxima revisión
Revisión previa
ecce.c [2022/11/19 00:41] – creado peronecce.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://ecce.sourceforge.net/ecce.c +
-   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 ecce.c +
- +
-   You may need to do: export LC_ALL=en_US.UTF-8 +
- +
-   Although it's reasonable portable C, there are now +
-   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.  Look for *SYS* +
-   in the source below.  Feedback portability improvements +
-   to gtoal@gtoal.com please.  Note that we assume that +
-   even a linux system is single-user.  The use of +
-   tmpnam() for saving in an emergency is potentially +
-   unsafe in a multi-user environment if there are +
-   bad actors. +
- +
-   Version 2.10a adds support for more robust embedding +
-   of ecce in Emacs, by making a version of the "-command" +
-   parameter (-hex-command) accept a hex string in order +
-   to pass the ecce command as a parameter while avoiding +
-   problems such as the use of " characters in the ecce command. +
- +
- +
-*SYS* +
-Add this to your ~/.emacs file (or some equivalent for Windows): +
- +
-;; hex encoding needed below. Came from https://github.com/jwiegley/emacs-release/blob/master/lisp/hex-util.el +
-(eval-when-compile +
-  (defmacro num-to-hex-char (num) +
-    `(aref "0123456789abcdef" ,num)) +
-  ) +
- +
-(defun encode-hex-string (string) +
-  "Encode octet STRING to hexadecimal 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) +
-                         "/bin/bash" +
-                         t t nil +
-                         "-c" +
-                         (concat "ecce - - -hex-command " +
-                                 (concat (encode-hex-string (concat (concat (format "(r,m)%d(l,m-r0)?\n" (point)) ecce_command) +
-                                                                    (format "\ni/%%EMACS%dCURSOR%%/\n%%c" (+ 495620 oldpoint)) +
-                                                                    ) +
-                         ) " 2> ~/.ecce-emacs.err")) +
-    ) +
-    (goto-char (point-min)) +
-    (search-forward (format "%%EMACS%dCURSOR%%" (+ 495620 oldpoint))) +
-    (replace-match "" nil nil) +
-  ) +
-+
- +
-(global-set-key "\C-e" 'e) +
- +
- */ +
 #define VERSION "V2.10b" /* %V */ #define VERSION "V2.10b" /* %V */
  static const char *RCS_Version = "$Revision: 1.4 $"; /* only relevant to my home linux /usr/local/src/ecce */  static const char *RCS_Version = "$Revision: 1.4 $"; /* only relevant to my home linux /usr/local/src/ecce */
Línea 103: Línea 31:
 /*                                                */ /*                                                */
 /*                                                */ /*                                                */
-/*     ECCE was designed by Hamish Dewar, now     */ +/*     ECCE fue diseñado por Hamish Dewar, ahora  */ 
-/* retired.  This implementation is by Graham     */ +/* retirado.  Esta implementación es de Graham    */ 
-/* 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 authorwithout restriction.            */+/* público por su autorsin restricciones        */
 /*                                                */ /*                                                */
 /* (c) Graham Toal, 1984. (Original BCPL version, */ /* (c) Graham Toal, 1984. (Original BCPL version, */
Línea 525: Línea 453:
   if (('A' <= c) && (c <= 'F')) return c - 'A' + 10;   if (('A' <= c) && (c <= 'F')) return c - 'A' + 10;
   if (('a' <= c) && (c <= 'f')) return c - 'a' + 10;   if (('a' <= c) && (c <= 'f')) return c - 'a' + 10;
-  fprintf(stderr, "%s: hex-command parameter corrupt - char '%c' is not hex\n", ProgName, c);+  fprintf(stderr, "%s: hex-command parámetro corrupto - char '%c' no es hex\n", ProgName, c);
   exit(1);   exit(1);
 } }
Línea 532: Línea 460:
   static char commandline[Max_parameter], *f, *t;   static char commandline[Max_parameter], *f, *t;
   if (strlen(hex)/2+3 >= Max_parameter) {   if (strlen(hex)/2+3 >= Max_parameter) {
-    fprintf(stderr, "%s: hex-command parameter was too long.\n", ProgName);+    fprintf(stderr, "%s: hex-command parámetro muy largo.\n", ProgName);
     exit(1);     exit(1);
   }   }
Línea 541: Línea 469:
     c1 = h(*f++);     c1 = h(*f++);
     if (*f == '\0') {     if (*f == '\0') {
-      fprintf(stderr, "%s: hex-command parameter corrupt. (Odd noof chars)\n", ProgName);+      fprintf(stderr, "%s: hex-command parámetro corrupto. (nroimpar de caracteres)\n", ProgName);
       exit(1);       exit(1);
     }     }
Línea 587: Línea 515:
       int offset = 1;       int offset = 1;
       if (argv[argno][1] == '-') offset += 1;       if (argv[argno][1] == '-') offset += 1;
-      if (strcmp(argv[argno]+offset, "from") == 0) {+      if (strcmp(argv[argno]+offset, "desde") == 0) {
         parameter[F] = argv[argno+1];         parameter[F] = argv[argno+1];
-      } else if (strcmp(argv[argno]+offset, "to") == 0) {+      } else if (strcmp(argv[argno]+offset, "a") == 0) {
         parameter[T] = argv[argno+1];         parameter[T] = argv[argno+1];
       } else if (strcmp(argv[argno]+offset, "log") == 0) {       } else if (strcmp(argv[argno]+offset, "log") == 0) {
Línea 595: Línea 523:
       } else if (strcmp(argv[argno]+offset, "hex-command") == 0) {       } else if (strcmp(argv[argno]+offset, "hex-command") == 0) {
         if (parameter[C] != NULL) {         if (parameter[C] != NULL) {
-          fprintf(stderr, "%s: only one -hex-command \"...\" or -command \"...\" is allowed\n", ProgName);+          fprintf(stderr, "%s: solo un -hex-command \"...\" -comando \"...\" se permite\n", ProgName);
           exit(1);           exit(1);
         }         }
Línea 611: Línea 539:
         buffer_size = strtoul(buf_size_str, &endptr, 10);         buffer_size = strtoul(buf_size_str, &endptr, 10);
         if (errno != 0) {         if (errno != 0) {
-          fprintf(stderr, "%s: bad size parameter '%s'\n", ProgName, buf_size_str);+          fprintf(stderr, "%s: parámetro de tamaño incorrecto '%s'\n", ProgName, buf_size_str);
           exit(1);           exit(1);
  }  }
Línea 622: Línea 550:
    } else {    } else {
             fprintf(stderr,             fprintf(stderr,
-                    "%s: bad unit type '%s' (expected %luK or %luM)\n",+                    "%s: tipo incorrecto de unidad '%s' (se espera %luK %luM)\n",
                     ProgName, endptr, buffer_size, buffer_size);                     ProgName, endptr, buffer_size, buffer_size);
             exit(1);             exit(1);
Línea 629: Línea 557:
       } else {       } else {
         fprintf (stderr,         fprintf (stderr,
-                 "%s: unknown option '%s'\n",+                 "%s: Opción desconocida '%s'\n",
  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,
-         "%s: {-frominfile {{-to} outfile}? {-log file}? {-{hex-}command 'commands;%%c'} {-size bytes}?\n",+         "%s: {-desdefichero_entrada {{-to} fichero_salida}? {-log fichero}? {-{hex-}comando 'comandos;%%c'} {-tamaño_ bytes}?\n",
           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, "%s: \"-command '...'\" option required when input file is standard input\n", ProgName); exit(1);+        fprintf(stderr, "%s: \"-comando '...'\" opción requerida cuando el fichero de entrada es la entrada estándar\n", ProgName); exit(1);
       }        } 
       main_in = stdin;       main_in = stdin;
Línea 665: Línea 593:
       tty_in = fopen("/dev/tty", "rb"); /*SYS*/       tty_in = fopen("/dev/tty", "rb"); /*SYS*/
       if (tty_in) {       if (tty_in) {
- fprintf(stderr, "%s: using /dev/tty for command input\n", ProgName);+ fprintf(stderr, "%s: usando /dev/tty para entrada de comando\n", ProgName);
       } else {       } else {
             tty_in = fopen("CON:", "r");             tty_in = fopen("CON:", "r");
             if (tty_in) {              if (tty_in) { 
-        fprintf(stderr, "%s: using CON: for command input\n", ProgName);+        fprintf(stderr, "%s: usando CON: para entrada de comando\n", ProgName);
      } else {      } else {
                tty_in = fopen("/dev/null", "rb");                tty_in = fopen("/dev/null", "rb");
                if (tty_in == NULL) tty_in = fopen("NUL:", "rb");                if (tty_in == NULL) tty_in = fopen("NUL:", "rb");
-        fprintf(stderr, "%s: warning - no command input stream\n", ProgName);+        fprintf(stderr, "%s: cuidado - no hay cadena de entrado de comando\n", ProgName);
                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 \"%s\" not found\n", parameter[F]);+      fprintf (stderr, "Fichero \"%s\" no encontrado\n", parameter[F]);
       exit (30);       exit (30);
    }    }
Línea 691: Línea 619:
       log_out = fopen (parameter[L], "wb");       log_out = fopen (parameter[L], "wb");
       if (log_out == NULL) {       if (log_out == NULL) {
-         fprintf (stderr, "%s: Warning can't create \"%s\"\n",+         fprintf (stderr, "%s: Cuidado No puedo crear \"%s\"\n",
           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);
    }    }
  
-   fprintf (stderr, "Buffer space = %d KBytes\n", (int)(buffer_size>>10));+   fprintf (stderr, "Espacio de Almacén = %d KBytes\n", (int)(buffer_size>>10));
  
  
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:
          fprintf (tty_out, "/UTF8");          fprintf (tty_out, "/UTF8");
 #endif #endif
-         fprintf (tty_out, " in C %s\n", DATE+7);+         fprintf (tty_out, " en C %s\n", DATE+7);
          break;          break;
  
Línea 941: Línea 869:
  if ((strcmp(parameter[parameter[T] == NULL ? F : T], "-") == 0) ||  if ((strcmp(parameter[parameter[T] == NULL ? F : T], "-") == 0) ||
             ((parameter[T] != NULL) && (strcmp(parameter[T], "/dev/stdout") == 0))) { /*SYS*/             ((parameter[T] != NULL) && (strcmp(parameter[T], "/dev/stdout") == 0))) { /*SYS*/
-           fprintf(stderr, "* %%W is not allowed when the output file is stdout\n");+           fprintf(stderr, "* %%W no está permitido cuando la salida del fichero es stdout\n");
     break;     break;
  }  }
Línea 964: Línea 892:
             (void)strcpy (com_prompt, ">");             (void)strcpy (com_prompt, ">");
             if (sec_out == NULL) {             if (sec_out == NULL) {
-               (void) fail_with ("Cannot save context", ' ');+               (void) fail_with ("No puedo guardar contexto", ' ');
                break;                break;
             }             }
Línea 996: Línea 924:
             if (main_out == NULL) {             if (main_out == NULL) {
                fprintf(stderr,                fprintf(stderr,
-                       "Sorry - I can't save your edit (even %s failed)\n", backup_save);+                       "Lo siento, no puedo guardar su edición (incluso %s ha fallado)\n", backup_save);
                exit(90);                exit(90);
             }             }
-            fprintf (tty_out, "Ecce abandonedsaving to %s\n", parameter[inoutlog]);+            fprintf (tty_out, "Ecce abandonadoguardando en %s\n", parameter[inoutlog]);
          } else {          } else {
            if ((strcmp(parameter[inoutlog], "-") == 0) || (strcmp(parameter[inoutlog], "/dev/stdout") == 0)) /*SYS*/            if ((strcmp(parameter[inoutlog], "-") == 0) || (strcmp(parameter[inoutlog], "/dev/stdout") == 0)) /*SYS*/
Línea 1007: Línea 935:
             if (main_out == NULL) {             if (main_out == NULL) {
                fprintf (stderr,                fprintf (stderr,
-                        "Can't create \"%s\"attempting to save to %s instead\n",+                        "No puedo crear \"%s\"intento guardarlo en %s en su lugar\n",
                         parameter[inoutlog], backup_save);                         parameter[inoutlog], backup_save);
                main_out = fopen (backup_save, "w");                main_out = fopen (backup_save, "w");
                if (main_out == NULL) {                if (main_out == NULL) {
-                 fprintf(stderr, "Cannot save file at all Giving up Sorry!\n");+                 fprintf(stderr, "Imposible guardar fichero de todos modosMe rindoLo siento!\n");
                  exit(1);                  exit(1);
         }         }
Línea 1017: Línea 945:
                if (inoutlog == T) {                if (inoutlog == T) {
                   fprintf (tty_out,                   fprintf (tty_out,
-                           "Ecce %s to %s completing.\n", parameter[F], parameter[T]);+                           "Ecce %s %s completando.\n", parameter[F], parameter[T]);
                } 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);
          }          }
-         fprintf (stderr, "\nAborted!\n");+         fprintf (stderr, "\nAbortado!\n");
          free_buffers ();          free_buffers ();
          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) {
-               (void) fail_with ("Cannot save context", ' ');+               (void) fail_with ("No puede guardar contexto", ' ');
                return;                return;
             }             }
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);
                }                }
                return;                return;
Línea 1147: Línea 1075:
                *P++ = sym;                *P++ = sym;
                if (P == fend) {                if (P == fend) {
-                  (void) fail_with ("%S corrupt no room", ' ');+                  (void) fail_with ("%S corrupto sin espacio", ' ');
                   fclose (sec_in);                   fclose (sec_in);
                   return;                   return;
Línea 1160: Línea 1088:
  
       default:       default:
-         (void) fail_with ("Percent", Command_sym);+         (void) fail_with ("Porciento", Command_sym);
    }    }
    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) {
-               fprintf (tty_out, "*** Note ***");+               fprintf (tty_out, "*** Nota ***");
                if (i == lbeg) fputc ('\n', tty_out);                if (i == lbeg) fputc ('\n', tty_out);
             }             }
Línea 1216: Línea 1144:
             } else fputc (sym, tty_out);             } else fputc (sym, tty_out);
          }          }
-         if (i == fend) fprintf (tty_out, "*** End ***");+         if (i == fend) fprintf (tty_out, "*** Fin ***");
          fputc ('\n', tty_out);          fputc ('\n', tty_out);
          if (repeat_count == 1L) return;          if (repeat_count == 1L) return;
Línea 1562: Línea 1490:
  
       default:       default:
-         (void) fail_with ("Unrecognised command", command);+         (void) fail_with ("Comando desconocido", command);
          return;          return;
    }    }
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) {
-         return (fail_with ("Command", command));+         return (fail_with ("Comando", command));
       }       }
       if ((type & delim) != 0) {       if ((type & delim) != 0) {
-         return (fail_with ("Command before", command));+         return (fail_with ("Comando antes", command));
       }       }
       if ((type & numb) != 0) {       if ((type & numb) != 0) {
-         return (fail_with ("Unexpected repetition count", command));+         return (fail_with ("Conteo de repetición inesperado", command));
       }       }
       limit = 0L;       limit = 0L;
Línea 1695: Línea 1623:
                unchain ();                unchain ();
                if (pointer >= 0) {                if (pointer >= 0) {
-                  return (fail_with ("Missing", ')'));+                  return (fail_with ("Faltante", ')'));
                }                }
                max_unit = this_unit;                max_unit = this_unit;
Línea 1722: Línea 1650:
                unchain ();                unchain ();
                if (pointer < 0) {                if (pointer < 0) {
-                  return (fail_with ("Missing", '('));+                  return (fail_with ("Faltante", '('));
                }                }
                num[pointer] = repeat_count;                num[pointer] = repeat_count;
Línea 1743: Línea 1671:
         *p++ = sym;         *p++ = sym;
         if (p == fend) {         if (p == fend) {
-           fprintf (stderr, "File too large!\n");+           fprintf (stderr, "Fichero muy grande!\n");
            percent ('A');            percent ('A');
         }         }
Línea 1751: Línea 1679:
 #ifdef WANT_UTF8 #ifdef WANT_UTF8
       if (errno == EILSEQ) {       if (errno == EILSEQ) {
- fprintf(stderr, "An invalid wide character was encountered You may need to do: export LC_ALL=en_US.UTF-8\n");  /*SYS*/+ fprintf(stderr, "Se encontró un caracter ancho inválidoPuede necesitar ejecutar: export LC_ALL=en_US.UTF-8\n");  /*SYS*/
  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. */
-               return (fail_with ("Failure:", culprit));+               return (fail_with ("Fallo:", culprit));
             }             }
           /* end of seq */           /* end of seq */
Línea 2047: Línea 1975:
    return (ok = FALSE);    return (ok = FALSE);
 } }
-</code>+</file>

Este sitio web utiliza cookies para guardar datos esenciales de su actividad, como su autenticación. Al entrar acepta el uso de cookies.

Más información