~ubuntu-branches/ubuntu/wily/luatex/wily

« back to all changes in this revision

Viewing changes to source/texk/kpathsea/mingw32.c

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2010-04-29 00:47:19 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20100429004719-o42etkqe90n97b9e
Tags: 0.60.1-1
* new upstream release, adapt build-script patch
* disable patch: upstream-epstopdf_cc_no_xpdf_patching, included upstream
* disable patch: libpoppler-0.12, not needed anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* mingw32.c: bits and pieces for mingw32
2
2
 
3
 
   Copyright 2009 Taco Hoekwater <taco@luatex.org>.
 
3
   Copyright 2009, 2010 Taco Hoekwater <taco@luatex.org>.
4
4
 
5
5
   This library is free software; you can redistribute it and/or
6
6
   modify it under the terms of the GNU Lesser General Public
42
42
extern int __cdecl _set_osfhnd (int fd, long h);
43
43
extern int __cdecl _free_osfhnd (int fd);
44
44
 
45
 
int _parse_root (char * name, char ** pPath);
 
45
static char *get_home_directory (void);
 
46
static int _parse_root (char * name, char ** pPath);
46
47
 
47
48
void
48
49
init_user_info (void)
73
74
  }
74
75
}
75
76
 
76
 
/* This function could go away */
77
 
void 
78
 
set_home_warning (void) 
79
 
{
80
 
}
81
 
 
82
77
/* Returns the home directory, in external format */
83
 
char *
 
78
static char *
84
79
get_home_directory (void)
85
80
{
86
81
    char *found_home_directory = NULL;
163
158
   drive specifier or double path separator.
164
159
*/
165
160
 
166
 
int
 
161
static int
167
162
normalize_filename (char *fp, char path_sep)
168
163
{
169
164
  char *p;
218
213
}
219
214
 
220
215
/* Destructively turn slashes into backslashes.  */
221
 
void
 
216
static void
222
217
unixtodos_filename (char *p)
223
218
{
224
219
  normalize_filename (p, '\\');
227
222
/* Remove all CR's that are followed by a LF.
228
223
   (From msdos.c...probably should figure out a way to share it,
229
224
   although this code isn't going to ever change.)  */
230
 
int
 
225
#if 0 /* unused */
 
226
static int
231
227
crlf_to_lf (int n, unsigned char *buf, unsigned *lf_count)
232
228
{
233
229
  unsigned char *np = buf;
256
252
    }
257
253
  return np - startp;
258
254
}
 
255
#endif
259
256
 
260
257
/* Parse the root part of file name, if present.  Return length and
261
258
    optionally store pointer to char after root.  */
262
 
int
 
259
static int
263
260
_parse_root (char * name, char ** pPath)
264
261
{
265
262
  char * start = name;
389
386
  This does make sense only under WIN32.
390
387
  Functions:
391
388
    - look_for_cmd() : locates an executable file
392
 
    - parse_cmd_line() : splits a command with pipes and redirections
393
 
    - build_cmd_line() : builds a command with pipes and redirections (useful ?)
 
389
    - parse_cmdline() : splits a command with pipes and redirections
 
390
    - build_cmdline() : builds a command with pipes and redirections (useful ?)
394
391
  */
395
392
 
396
393
/*
400
397
*/
401
398
 
402
399
BOOL 
403
 
#if 0
404
 
look_for_cmd(const char *cmd, char **app, char **new)
405
 
#else
406
400
look_for_cmd(const char *cmd, char **app)
407
 
#endif
408
401
{
409
402
  char *env_path;
410
 
  char *p, *q;
 
403
  const char *p, *q;
411
404
  char pname[MAXPATHLEN], *fp;
412
 
  char *suffixes[] = { ".bat", ".cmd", ".com", ".exe", NULL };
413
 
  char **s;
414
 
#if 1
415
 
  char **new;
416
 
#endif
417
 
  char *app_name, *new_cmd;
 
405
  const char *suffixes[] = { ".bat", ".cmd", ".com", ".exe", NULL };
 
406
  const char **s;
 
407
  char *app_name;
418
408
 
419
409
  BOOL go_on;
420
410
 
421
 
  *new = *app = NULL;
422
 
  new_cmd = app_name = NULL;
 
411
  *app = NULL;
 
412
  app_name = NULL;
423
413
 
424
414
  /* We should look for the application name along the PATH,
425
415
     and decide to prepend "%COMSPEC% /c " or not to the command line.
431
421
  */
432
422
 
433
423
  /* Look for the application name */
434
 
  for (p = (char *)cmd; *p && isspace(*p); p++);
 
424
  for (p = cmd; *p && isspace(*p); p++);
435
425
  if (*p == '"') {
436
426
    q = ++p;
437
427
    while(*p && *p != '"') p++;
473
463
#ifdef TRACE
474
464
      fprintf(stderr, "%s found with suffix %s\nin %s\n", app_name, *s, pname);
475
465
#endif
476
 
      new_cmd = xstrdup(cmd);
477
466
      free(app_name);
478
467
      app_name = xstrdup(pname);
479
468
      break;
485
474
#ifdef TRACE
486
475
    fprintf(stderr, "%s not found, concatenating comspec\n", app_name);
487
476
#endif
488
 
    new_cmd = concatn(getenv("COMSPEC"), " /c ", cmd, NULL);
489
477
    free(app_name);
490
478
    app_name = NULL;
491
479
  }
492
 
  else {
493
 
  }
494
480
  if (env_path) free(env_path);
495
481
 
496
 
  *new = new_cmd;
497
482
  *app = app_name;
498
483
 
499
484
  return TRUE;
649
634
  What we allow :
650
635
  [cmd] [arg1] ... [argn] < [redinput] | [cmd2] | ... | [cmdn] > [redoutput]
651
636
*/
652
 
void *parse_cmdline(char *line, char **input, char **output)
 
637
static void *
 
638
parse_cmdline(char *line, char **input, char **output)
653
639
{
654
640
  BOOL again, needcmd = TRUE, bSuccess = TRUE, append_out = FALSE;
655
641
  char *beg = line, *end, *new_end;
821
807
  return xstrdup(elt);
822
808
}
823
809
 
824
 
/* static (commented out for mingw; SK) */ char *
 
810
char *
825
811
quote_args(char **argv)
826
812
{
827
813
  int i;
843
829
  return line;
844
830
}
845
831
 
846
 
char *
 
832
static char *
847
833
build_cmdline(char ***cmd, char *input, char *output)
848
834
{
849
835
  int ncmd;
878
864
  under Win9x. This is a workaround for this bug.
879
865
*/
880
866
 
881
 
int win32_system(const char *cmd, int async)
 
867
int
 
868
win32_system(const char *cmd, int async)
882
869
{
883
870
  STARTUPINFO si;
884
871
  PROCESS_INFORMATION pi;
904
891
    return 1;
905
892
  }
906
893
 
907
 
#if 0
908
 
  if (look_for_cmd(cmd, &app_name, &new_cmd) == FALSE) {
909
 
#else
910
 
  new_cmd = xstrdup(cmd);
911
894
  if (look_for_cmd(cmd, &app_name) == FALSE) {
912
 
    if (new_cmd) free(new_cmd);
913
 
#endif
914
895
    /* Failed to find the command or malformed cmd */
915
896
    errno = ENOEXEC;
916
897
#ifdef _TRACE
919
900
    return -1;
920
901
  }
921
902
 
 
903
  new_cmd = xstrdup(cmd);
922
904
  cmd_pipe = parse_cmdline(new_cmd, &red_input, &red_output);
923
905
 
924
906
  for (i = 0; cmd_pipe[i]; i++) {