sistema_progs

Programas para customizar o meu entorno de traballo nos meus equipos persoais
Log | Files | Refs

mc-debug.patch (3122B)


      1 diff --git a/src/subshell/common.c b/src/subshell/common.c
      2 index 3ea4b5ff7..b63678ca3 100644
      3 --- a/src/subshell/common.c
      4 +++ b/src/subshell/common.c
      5 @@ -702,6 +702,33 @@ clear_subshell_prompt_string (void)
      6  static void
      7  parse_subshell_prompt_string (const char *buffer, int bytes)
      8  {
      9 +  {
     10 +    int i;
     11 +    FILE* f = fopen("a.txt", "a");
     12 +    fprintf(f, "data: ");
     13 +    for (i = 0; i < bytes; i++) {
     14 +      char c = buffer[i];
     15 +      if (c < 0x20 || c >= 0x7F) {
     16 +        const char* name = NULL;
     17 +        switch (c) {
     18 +        case 0x1B: name = "ESC"; break;
     19 +        case 0x0D: name = "CR"; break;
     20 +        case 0x0A: name = "LF"; break;
     21 +        default:
     22 +        }
     23 +        if (name)
     24 +          fprintf(f, "\x1b[7m%s\x1b[m", name);
     25 +        else
     26 +          fprintf(f, "\x1b[7mx%02X\x1b[m", (unsigned)buffer[i]);
     27 +      } else
     28 +        fprintf(f, "%c", c);
     29 +    }
     30 +    fprintf(f, "\nhex:");
     31 +    for (i = 0; i < bytes; i++) fprintf(f, " %02x", (unsigned)buffer[i]);
     32 +    fprintf(f, "\n");
     33 +    fclose(f);
     34 +  }
     35 +
     36      int i;
     37  
     38      if (mc_global.mc_run_mode != MC_RUN_FULL)
     39 @@ -748,6 +775,12 @@ feed_subshell (int how, gboolean fail_on_error)
     40      struct timeval wtime;       /* Maximum time we wait for the subshell */
     41      struct timeval *wptr;
     42  
     43 +    if (should_read_new_subshell_prompt)
     44 +      {
     45 +        FILE* file = fopen("/dev/pts/9", "w");
     46 +        fprintf(file, "should_read_new_subshell_prompt clear\n");
     47 +        fclose(file);
     48 +      }
     49      should_read_new_subshell_prompt = FALSE;
     50  
     51      /* have more than enough time to run subshell:
     52 @@ -820,6 +853,12 @@ feed_subshell (int how, gboolean fail_on_error)
     53              if (how == VISIBLY)
     54                  write_all (STDOUT_FILENO, pty_buffer, bytes);
     55  
     56 +            if (should_read_new_subshell_prompt)
     57 +              {
     58 +                FILE* file = fopen("/dev/pts/9", "w");
     59 +                fprintf(file, "should_read_new_subshell_prompt\n");
     60 +                fclose(file);
     61 +              }
     62              if (should_read_new_subshell_prompt)
     63                  parse_subshell_prompt_string (pty_buffer, bytes);
     64          }
     65 @@ -842,6 +881,11 @@ feed_subshell (int how, gboolean fail_on_error)
     66  
     67              clear_subshell_prompt_string ();
     68              should_read_new_subshell_prompt = TRUE;
     69 +            {
     70 +              FILE* file = fopen("/dev/pts/9", "w");
     71 +              fprintf(file, "cwd: %s\n", subshell_cwd);
     72 +              fclose(file);
     73 +            }
     74              subshell_ready = TRUE;
     75              if (subshell_state == RUNNING_COMMAND)
     76              {
     77 @@ -853,6 +897,12 @@ feed_subshell (int how, gboolean fail_on_error)
     78          else if (FD_ISSET (STDIN_FILENO, &read_set))
     79              /* Read from stdin, write to the subshell */
     80          {
     81 +            if (should_read_new_subshell_prompt)
     82 +              {
     83 +                FILE* file = fopen("/dev/pts/9", "w");
     84 +                fprintf(file, "should_read_new_subshell_prompt unset\n");
     85 +                fclose(file);
     86 +              }
     87              should_read_new_subshell_prompt = FALSE;
     88              bytes = read (STDIN_FILENO, pty_buffer, sizeof (pty_buffer));
     89              if (bytes <= 0)