~ubuntu-branches/ubuntu/utopic/texlive-bin/utopic

« back to all changes in this revision

Viewing changes to utils/mtx/mtx-0.60d/cfuncs.c

  • Committer: Package Import Robot
  • Author(s): Norbert Preining
  • Date: 2012-05-07 10:47:49 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20120507104749-p00ot5sajjbkp1hp
Tags: 2011.20120507-1
* new upstream checkout: uptex 1.10
* drop patches for config file inclusion in (x)dvipdfmx, included upstream
* add man page for etex
* include pmpost patches and build it
* adapt/unfuzzify patches for current sources
* disable mtx building, we have prepmx package in Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# define CFUNCS_C
 
2
#include "cfuncs.h"
 
3
 
 
4
int P_argc;
 
5
char **P_argv;
 
6
int P_ioresult;
 
7
int _EscIO2 (int errorcode, char* filename)
 
8
{ fprintf(stderr,"Input file %s not found\n",filename); 
 
9
  exit(errorcode); return errorcode; }
 
10
int _EscIO (int errorcode){ return _EscIO2(errorcode,""); }
 
11
int _Escape (int exitcode)
 
12
{ exit(exitcode); return exitcode; }
 
13
int _SETIO (int OK, int errorcode){ return P_ioresult = OK ? 0 : errorcode; }
 
14
int P_eof (FILE * infile)
 
15
{ int x;
 
16
  if (feof(infile)) return 1; 
 
17
  x = fgetc(infile);
 
18
  if (x==EOF) return 1;
 
19
  ungetc(x,infile); return 0;
 
20
  }
 
21
void PASCAL_MAIN (int npars, char ** pars)
 
22
{ P_argc = npars; P_argv = pars; }
 
23
 
 
24
void scan1(char *s, short p, short *n)
 
25
{ sscanf(s+p-1,"%hd",n);
 
26
}
 
27
 
 
28
short pos1(char c, char *s)
 
29
{ char *t = strchr(s,c);
 
30
  if (t) return (short) (t-s+1); else return 0;
 
31
}
 
32
 
 
33
void delete1(char *s, short p)
 
34
{ char *t = (s+=p); s=t-1;
 
35
  while (*s) *s++ = *t++;
 
36
}
 
37
 
 
38
void predelete(char *s, short l)
 
39
{ char *t = s+l;
 
40
  while (*t) *s++ = *t++;
 
41
  *s = *t;
 
42
}
 
43
 
 
44
void shorten(char *s, short new_length)
 
45
{ s[new_length] = '\0';
 
46
}
 
47
 
 
48
short posNot(char c, char *s)
 
49
{ char *t = s;
 
50
  while (*t == c) t++;
 
51
  if (*t) return t-s+1;
 
52
  else return 0;
 
53
}
 
54
 
 
55
void getNum(char *line, short *k)
 
56
{ int j=sscanf(line,"%hd",k);
 
57
  if (j<1) *k=0;
 
58
}
 
59
 
 
60
 
 
61
void getTwoNums(char *line, short *k1, short *k2)
 
62
{ int param = sscanf(line,"%hd/%hd",k1,k2);
 
63
  if (param<2) *k2 = 0;
 
64
}
 
65
 
 
66
void toUpper(char *s)
 
67
{ while (*s) { *s = toupper(*s); s++; }
 
68
}
 
69
 
 
70
boolean startsWith(char *s1, char *s2)
 
71
{ while (*s2) { if (*s1++ != *s2++) return false; }
 
72
  return true;
 
73
}
 
74
 
 
75
void insertChar(char c, char *s, short p)
 
76
{ char x;
 
77
   s += p-1;
 
78
   do { x=c; c=*s; *s++=x; } while (x);
 
79
}
 
80
 
 
81
char *substr_(char *Result, char *s, short start, short count)
 
82
{ char *R = Result;
 
83
  s += start-1;
 
84
  while (count--) *R++ = *s++;
 
85
  *R = '\0';
 
86
  return Result;
 
87
}
 
88
 
 
89
# undef CFUNCS_C