diff --git a/src/args.c b/src/args.c
index 15bd506..b55f401 100644
a
|
b
|
mc_setup_by_args (int argc, char *argv[]) |
516 | 516 | |
517 | 517 | if (tmp != NULL) |
518 | 518 | mc_run_param0 = g_strdup (tmp); |
| 519 | #ifdef HAVE_UNISTD_H |
| 520 | /* If fd0 is non-interactive, a file is being piped */ |
| 521 | else if (!isatty(fileno(stdin))) |
| 522 | mc_run_param0 = g_strdup("-"); |
| 523 | #endif |
519 | 524 | else |
520 | 525 | { |
521 | 526 | fprintf (stderr, "%s\n", _("No arguments given to the viewer.")); |
diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c
index 765bc82..e85eea3 100644
a
|
b
|
prepend_cwd_on_local (const char *filename) |
907 | 907 | size_t l; |
908 | 908 | vfs_path_t *vpath; |
909 | 909 | |
| 910 | if (filename[0] == '-') /* don't let it reach vfs */ |
| 911 | return g_strdup (filename); |
| 912 | |
910 | 913 | vpath = vfs_path_from_str (filename); |
911 | 914 | if (!vfs_file_is_local (vpath) || g_path_is_absolute (filename)) |
912 | 915 | { |
diff --git a/src/viewer/datasource.c b/src/viewer/datasource.c
index 008183e..fde7399 100644
a
|
b
|
mcview_set_datasource_stdio_pipe (mcview_t * view, FILE * fp) |
91 | 91 | /* --------------------------------------------------------------------------------------------- */ |
92 | 92 | |
93 | 93 | void |
| 94 | mcview_set_datasource_stdin_pipe (mcview_t * view) |
| 95 | { |
| 96 | view->datasource = DS_STDIN_PIPE; |
| 97 | view->ds_stdio_pipe = stdin; |
| 98 | |
| 99 | mcview_growbuf_init (view); |
| 100 | } |
| 101 | |
| 102 | /* --------------------------------------------------------------------------------------------- */ |
| 103 | |
| 104 | void |
94 | 105 | mcview_set_datasource_none (mcview_t * view) |
95 | 106 | { |
96 | 107 | view->datasource = DS_NONE; |
… |
… |
mcview_get_filesize (mcview_t * view) |
106 | 117 | case DS_NONE: |
107 | 118 | return 0; |
108 | 119 | case DS_STDIO_PIPE: |
| 120 | case DS_STDIN_PIPE: |
109 | 121 | case DS_VFS_PIPE: |
110 | 122 | return mcview_growbuf_filesize (view); |
111 | 123 | case DS_FILE: |
… |
… |
mcview_get_utf (mcview_t * view, off_t byte_index, int *char_width, gboolean * r |
171 | 183 | switch (view->datasource) |
172 | 184 | { |
173 | 185 | case DS_STDIO_PIPE: |
| 186 | case DS_STDIN_PIPE: |
174 | 187 | case DS_VFS_PIPE: |
175 | 188 | str = mcview_get_ptr_growing_buffer (view, byte_index); |
176 | 189 | break; |
… |
… |
mcview_close_datasource (mcview_t * view) |
318 | 331 | } |
319 | 332 | mcview_growbuf_free (view); |
320 | 333 | break; |
| 334 | case DS_STDIN_PIPE: |
| 335 | view->ds_stdio_pipe = NULL; |
| 336 | mcview_growbuf_free (view); |
| 337 | break; |
321 | 338 | case DS_VFS_PIPE: |
322 | 339 | if (view->ds_vfs_pipe != -1) |
323 | 340 | { |
diff --git a/src/viewer/growbuf.c b/src/viewer/growbuf.c
index a98bf93..05a9657 100644
a
|
b
|
mcview_growbuf_read_until (mcview_t * view, off_t ofs) |
150 | 150 | return; |
151 | 151 | } |
152 | 152 | } |
| 153 | else if (view->datasource == DS_STDIN_PIPE) |
| 154 | { |
| 155 | nread = fread (p, 1, bytesfree, view->ds_stdio_pipe); |
| 156 | if (nread == 0) |
| 157 | { |
| 158 | view->growbuf_finished = TRUE; |
| 159 | view->ds_stdio_pipe = NULL; |
| 160 | return; |
| 161 | } |
| 162 | } |
153 | 163 | else |
154 | 164 | { |
155 | 165 | assert (view->datasource == DS_VFS_PIPE); |
diff --git a/src/viewer/inlines.h b/src/viewer/inlines.h
index 8a3233f..3dfb349 100644
a
|
b
|
mcview_get_byte (mcview_t * view, off_t offset, int *retval) |
102 | 102 | switch (view->datasource) |
103 | 103 | { |
104 | 104 | case DS_STDIO_PIPE: |
| 105 | case DS_STDIN_PIPE: |
105 | 106 | case DS_VFS_PIPE: |
106 | 107 | return mcview_get_byte_growing_buffer (view, offset, retval); |
107 | 108 | case DS_FILE: |
diff --git a/src/viewer/internal.h b/src/viewer/internal.h
index 249df6c..75c6f94 100644
a
|
b
|
enum view_ds |
29 | 29 | { |
30 | 30 | DS_NONE, /* No data available */ |
31 | 31 | DS_STDIO_PIPE, /* Data comes from a pipe using popen/pclose */ |
| 32 | DS_STDIN_PIPE, /* Data comes from a pipe using standart input */ |
32 | 33 | DS_VFS_PIPE, /* Data comes from a piped-in VFS file */ |
33 | 34 | DS_FILE, /* Data comes from a VFS file */ |
34 | 35 | DS_STRING /* Data comes from a string in memory */ |
… |
… |
void mcview_ccache_lookup (mcview_t * view, coord_cache_entry_t * coord, |
228 | 229 | |
229 | 230 | /* datasource.c: */ |
230 | 231 | void mcview_set_datasource_none (mcview_t *); |
| 232 | void mcview_set_datasource_stdin_pipe (mcview_t *); |
231 | 233 | off_t mcview_get_filesize (mcview_t *); |
232 | 234 | void mcview_update_filesize (mcview_t * view); |
233 | 235 | char *mcview_get_ptr_file (mcview_t *, off_t); |
diff --git a/src/viewer/mcviewer.c b/src/viewer/mcviewer.c
index a67895b..7e5d851 100644
a
|
b
|
mcview_load (mcview_t * view, const char *command, const char *file, int start_l |
306 | 306 | |
307 | 307 | if (command != NULL && (view->magic_mode || file == NULL || file[0] == '\0')) |
308 | 308 | retval = mcview_load_command_output (view, command); |
| 309 | else if (file != NULL && file[0] == '-') |
| 310 | { |
| 311 | /* "-" is a special case, a standart input pipe */ |
| 312 | mcview_set_datasource_stdin_pipe (view); |
| 313 | retval = TRUE; |
| 314 | } |
309 | 315 | else if (file != NULL && file[0] != '\0') |
310 | 316 | { |
311 | 317 | int fd = -1; |