]> granicus.if.org Git - recode/commitdiff
Remove --sequence=files
authorReuben Thomas <rrt@sc3d.org>
Mon, 22 Jan 2018 22:22:09 +0000 (22:22 +0000)
committerReuben Thomas <rrt@sc3d.org>
Tue, 23 Jan 2018 07:16:15 +0000 (07:16 +0000)
Assume that any reasonable target OS has virtual memory (on which holding
the data in memory has much the same performance implications as using
files).

doc/recode.texi
src/main.c
src/recodext.h
src/task.c
tests/Recode.pyx
tests/t50_methods.py

index ea779708cc0e662010cc283e13fa4b6d41405527..dc6c34a1456135af4670e27885aa479ecce0994a 100644 (file)
@@ -1439,21 +1439,18 @@ behaviour, which is also explained below.
 @cindex memory sequencing
 When the recoding requires a combination of two or more elementary
 recoding steps, this option forces many passes over the data, using
-in-memory buffers to hold all intermediary results.
-@c This should be the default behaviour when
-@c files to be recoded are @emph{small} enough.
+in-memory buffers to hold all intermediate results.
+If this option is selected in filter
+mode, that is, when the program reads standard input and writes standard
+output, it might take longer for programs further down the pipe chain to
+start receiving some recoded data.
 
 @item -i
 @itemx --sequence=files
 @opindex -i
 @cindex file sequencing
-When the recoding requires a combination of two or more elementary
-recoding steps, this option forces many passes over the data, using
-intermediate files between passes.  This is the default behaviour when
-files are recoded over themselves.  If this option is selected in filter
-mode, that is, when the program reads standard input and writes standard
-output, it might take longer for programs further down the pipe chain to
-start receiving some recoded data.
+This option is accepted for backwards compatibility, and acts like
+@samp{--sequence=memory}.
 
 @item -p
 @itemx --sequence=pipe
@@ -2405,9 +2402,6 @@ the header file @file{recodext.h}.  Other possible values are:
 @item RECODE_SEQUENCE_IN_MEMORY
 @vindex RECODE_SEQUENCE_IN_MEMORY
 Keep intermediate recodings in memory.
-@item RECODE_SEQUENCE_WITH_FILES
-@vindex RECODE_SEQUENCE_WITH_FILES
-Do not fork, use intermediate files.
 @item RECODE_SEQUENCE_WITH_PIPE
 @vindex RECODE_SEQUENCE_WITH_PIPE
 Fork processes connected with @code{pipe(2)}.
index cd286a6ae79a718ba7dd9bd1c9b0b057b2658ce5..72a88a36b0eb1fec15a16a86467c54e2f0294959 100644 (file)
@@ -227,7 +227,6 @@ Operation modes:\n\
   -q, --quiet, --silent   inhibit messages about irreversible recodings\n\
   -f, --force             force recodings even when not reversible\n\
   -t, --touch             touch the recoded files after replacement\n\
-  -i, --sequence=files    use intermediate files for sequencing passes\n\
       --sequence=memory   use memory buffers for sequencing passes\n\
 "),
             stdout);
@@ -393,11 +392,8 @@ main (int argc, char *const *argv)
            usage (EXIT_FAILURE, 0);
 
          case 0:
-           task_option.strategy = RECODE_SEQUENCE_IN_MEMORY;
-           break;
-
          case 1:
-           task_option.strategy = RECODE_SEQUENCE_WITH_FILES;
+           task_option.strategy = RECODE_SEQUENCE_IN_MEMORY;
            break;
 
          case 2:
@@ -501,7 +497,7 @@ main (int argc, char *const *argv)
        break;
 
       case 'i':
-       task_option.strategy = RECODE_SEQUENCE_WITH_FILES;
+       task_option.strategy = RECODE_SEQUENCE_IN_MEMORY;
        break;
 
       case 'k':
@@ -789,13 +785,10 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"),
     if (optind < argc)
       {
        /* When reading and writing files, unless the user selected
-          otherwise, avoid forking and use intermediate files.  */
-
-       /* FIXME: On a file per file basis, force recoding to be done in
-          memory whenever files are small, which is the usual case.  */
+          otherwise, avoid forking and use memory.  */
 
        if (task->strategy == RECODE_STRATEGY_UNDECIDED)
-         task->strategy = RECODE_SEQUENCE_WITH_FILES;
+         task->strategy = RECODE_SEQUENCE_IN_MEMORY;
 
        /* In case files are recoded over themselves and there is no
           recoding step at all, do not even try to touch the files.  */
index dbd91b5da6cebbd57bbbac5171763ee70987a209..100c5f471be6e6e2c7b83cf07950d96174cc7a6d 100644 (file)
@@ -415,7 +415,6 @@ enum recode_sequence_strategy
   {
     RECODE_STRATEGY_UNDECIDED, /* sequencing strategy is undecided yet */
     RECODE_SEQUENCE_IN_MEMORY, /* keep intermediate recodings in memory */
-    RECODE_SEQUENCE_WITH_FILES,        /* do not fork, use intermediate files */
     RECODE_SEQUENCE_WITH_PIPE  /* fork processes connected with `pipe(2)' */
   };
 
index 0ba57cee87119a97dcac6ea95efc09f42d81aa55..04a15dfb5e123a2fdf586b36a0a6b2e026acc053 100644 (file)
@@ -260,7 +260,7 @@ perform_sequence (RECODE_TASK task, enum recode_sequence_strategy strategy)
       child_process = -1;
       subtask->output = task->output;
 
-      if (strategy == RECODE_SEQUENCE_IN_MEMORY || strategy == RECODE_SEQUENCE_WITH_FILES)
+      if (strategy == RECODE_SEQUENCE_IN_MEMORY)
        if (sequence_index > 0)
          {
            /* Select the input text for this step.  */
@@ -269,14 +269,6 @@ perform_sequence (RECODE_TASK task, enum recode_sequence_strategy strategy)
            subtask->input.cursor = input.buffer;
            subtask->input.limit = input.cursor;
            subtask->input.file = input.file;
-
-           if (strategy == RECODE_SEQUENCE_WITH_FILES &&
-               fseek (subtask->input.file, 0L, SEEK_SET) != 0)
-             {
-               recode_perror (NULL, "fseek (%s)", subtask->input.name);
-               recode_if_nogo (RECODE_SYSTEM_ERROR, subtask);
-               goto exit;
-             }
          }
 
       /* Select the output text for this step.  */
@@ -290,15 +282,6 @@ perform_sequence (RECODE_TASK task, enum recode_sequence_strategy strategy)
              subtask->output.cursor = subtask->output.buffer;
              break;
 
-           case RECODE_SEQUENCE_WITH_FILES:
-             if (subtask->output.file = tmpfile (), subtask->output.file == NULL)
-               {
-                 recode_perror (NULL, "tmpfile ()");
-                 recode_if_nogo (RECODE_SYSTEM_ERROR, subtask);
-                 goto exit;
-               }
-             break;
-
 #if HAVE_PIPE
            case RECODE_SEQUENCE_WITH_PIPE:
              /* Create all subprocesses, from the first to the last, and
@@ -401,7 +384,7 @@ perform_sequence (RECODE_TASK task, enum recode_sequence_strategy strategy)
            break;      /* parent process: escape from loop */
        }
 
-      if (strategy != RECODE_SEQUENCE_WITH_PIPE)
+      if (strategy == RECODE_SEQUENCE_IN_MEMORY)
        {
          /* Post-step clean up.  */
 
@@ -572,21 +555,14 @@ recode_perform_task (RECODE_TASK task)
     {
     case RECODE_SEQUENCE_WITH_PIPE:
 #if !HAVE_PIPE
-      strategy = RECODE_SEQUENCE_WITH_FILES;
+      strategy = RECODE_SEQUENCE_IN_MEMORY;
 #endif
     case RECODE_SEQUENCE_IN_MEMORY:
-    case RECODE_SEQUENCE_WITH_FILES:
       break;
 
-    case RECODE_STRATEGY_UNDECIDED:
     default: /* This should not happen, but if it does, try to recover.  */
-      /* Let's use only memory if either end is memory, or only temporary
-        files if both ends are files.  This is a crude choice, FIXME! */
-      if ((task->input.name || task->input.file)
-         && (task->output.name || task->output.file))
-       strategy = RECODE_SEQUENCE_WITH_FILES;
-      else
-       strategy = RECODE_SEQUENCE_IN_MEMORY;
+    case RECODE_STRATEGY_UNDECIDED:
+      strategy = RECODE_SEQUENCE_IN_MEMORY;
       break;
     }
 
index 11d85414e19e8ed76b06ad4038cbbbaf6f411ff5..8cf0fb7856556ba27172e9aa3c6e9ecd787ed494 100644 (file)
@@ -170,7 +170,6 @@ cdef extern from "common.h":
     enum recode_sequence_strategy:
         RECODE_STRATEGY_UNDECIDED
         RECODE_SEQUENCE_IN_MEMORY
-        RECODE_SEQUENCE_WITH_FILES
         RECODE_SEQUENCE_WITH_PIPE
 
     enum recode_swap_input:
@@ -488,7 +487,6 @@ EXPLODE_STEP = RECODE_EXPLODE_STEP
 
 STRATEGY_UNDECIDED = RECODE_STRATEGY_UNDECIDED
 SEQUENCE_IN_MEMORY = RECODE_SEQUENCE_IN_MEMORY
-SEQUENCE_WITH_FILES = RECODE_SEQUENCE_WITH_FILES
 SEQUENCE_WITH_PIPE = RECODE_SEQUENCE_WITH_PIPE
 
 SWAP_UNDECIDED = RECODE_SWAP_UNDECIDED
index 23f50449b33c9876a6b9aa1f6ce223d9678a62dc..6345c73ace1ee07b09dea88079f9695a1c0df7c8 100644 (file)
@@ -11,64 +11,48 @@ def test_1():
     # No step at all.
     yield validate, 'texte..texte', 'memory', 'filter'
     yield validate, 'texte..texte', 'memory', 'squash'
-    yield validate, 'texte..texte', 'files', 'filter'
-    yield validate, 'texte..texte', 'files', 'squash'
     yield validate, 'texte..texte', 'pipe', 'filter'
     yield validate, 'texte..texte', 'pipe', 'squash'
 
     # One single step.
     yield validate, 'latin1..ibmpc/', 'memory', 'filter'
     yield validate, 'latin1..ibmpc/', 'memory', 'squash'
-    yield validate, 'latin1..ibmpc/', 'files', 'filter'
-    yield validate, 'latin1..ibmpc/', 'files', 'squash'
     yield validate, 'latin1..ibmpc/', 'pipe', 'filter'
     yield validate, 'latin1..ibmpc/', 'pipe', 'squash'
 
     # One single step and a surface
     yield validate, 'latin1..ibmpc', 'memory', 'filter'
     yield validate, 'latin1..ibmpc', 'memory', 'squash'
-    yield validate, 'latin1..ibmpc', 'files', 'filter'
-    yield validate, 'latin1..ibmpc', 'files', 'squash'
     yield validate, 'latin1..ibmpc', 'pipe', 'filter'
     yield validate, 'latin1..ibmpc', 'pipe', 'squash'
 
     # One single step.
     yield validate, 'texte..latin1', 'memory', 'filter'
     yield validate, 'texte..latin1', 'memory', 'squash'
-    yield validate, 'texte..latin1', 'files', 'filter'
-    yield validate, 'texte..latin1', 'files', 'squash'
     yield validate, 'texte..latin1', 'pipe', 'filter'
     yield validate, 'texte..latin1', 'pipe', 'squash'
 
     # Two single steps.
     yield validate, 'texte..bangbang', 'memory', 'filter'
     yield validate, 'texte..bangbang', 'memory', 'squash'
-    yield validate, 'texte..bangbang', 'files', 'filter'
-    yield validate, 'texte..bangbang', 'files', 'squash'
     yield validate, 'texte..bangbang', 'pipe', 'filter'
     yield validate, 'texte..bangbang', 'pipe', 'squash'
 
     # Two single steps and a surface.
     yield validate, 'texte..ibmpc', 'memory', 'filter'
     yield validate, 'texte..ibmpc', 'memory', 'squash'
-    yield validate, 'texte..ibmpc', 'files', 'filter'
-    yield validate, 'texte..ibmpc', 'files', 'squash'
     yield validate, 'texte..ibmpc', 'pipe', 'filter'
     yield validate, 'texte..ibmpc', 'pipe', 'squash'
 
     # Three single steps.
     yield validate, 'texte..iconqnx', 'memory', 'filter'
     yield validate, 'texte..iconqnx', 'memory', 'squash'
-    yield validate, 'texte..iconqnx', 'files', 'filter'
-    yield validate, 'texte..iconqnx', 'files', 'squash'
     yield validate, 'texte..iconqnx', 'pipe', 'filter'
     yield validate, 'texte..iconqnx', 'pipe', 'squash'
 
     # Four single steps, optimized into three (with iconv) or two (without).
     yield validate, 'ascii-bs..ebcdic', 'memory', 'filter'
     yield validate, 'ascii-bs..ebcdic', 'memory', 'squash'
-    yield validate, 'ascii-bs..ebcdic', 'files', 'filter'
-    yield validate, 'ascii-bs..ebcdic', 'files', 'squash'
     yield validate, 'ascii-bs..ebcdic', 'pipe', 'filter'
     yield validate, 'ascii-bs..ebcdic', 'pipe', 'squash'