>>31 ls -Rだと勝手に解釈
#include <stdio.h>
static int trim_lsR_path(char *path, size_t size)
{
 int i;
 for (i = 0; i < size; i++)
   if (path[i] == ':')
     break;
 return path[i] == ':' && i >= 1 ? path[i] = '\0', 0 : -1;
}
int main(void)
{
 static char path[BUFSIZ], buf[BUFSIZ];
 FILE *fp;
 if ((fp = fopen("ls-R", "r")) == NULL)
   return 1;
 if (fgets(path, sizeof(path), fp) == NULL)
   goto err;
 if (trim_lsR_path(path, sizeof(path)) < 0)
   goto err;
 while (fgets(buf, sizeof(buf), fp) != NULL)
   if (!strcmp(buf, "\n")) {
     if (fgets(path, sizeof(path), fp) == NULL)
       goto err;
     if (trim_lsR_path(path, sizeof(path)) < 0)
       goto err;
   } else
     printf("%s/%s", path, buf);
 return fclose(fp), 0;
err:
 return fclose(fp), 1;
}