~ubuntu-branches/ubuntu/jaunty/texlive-bin/jaunty-security

« back to all changes in this revision

Viewing changes to build/source/libs/libgnuw32/string.c

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2008-06-26 23:14:59 UTC
  • mfrom: (2.1.30 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080626231459-y02rjsrgtafu83yr
Tags: 2007.dfsg.2-3
add missing source roadmap.fig of roadmap.eps in fontinst documentation
(Closes: #482915) (urgency medium due to RC bug)
(new patch add-missing-fontinst-source)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* libc replacement functions for win32.
 
2
 
 
3
Copyright (C) 1998, 99 Free Software Foundation, Inc.
 
4
 
 
5
This library is free software; you can redistribute it and/or
 
6
modify it under the terms of the GNU Library General Public
 
7
License as published by the Free Software Foundation; either
 
8
version 2 of the License, or (at your option) any later version.
 
9
 
 
10
This library is distributed in the hope that it will be useful,
 
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
Library General Public License for more details.
 
14
 
 
15
You should have received a copy of the GNU Library General Public
 
16
License along with this library; if not, write to the Free Software
 
17
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
18
 
 
19
#include <string.h>
 
20
#include <win32lib.h>
 
21
 
 
22
char *xstrdup(const char *s)
 
23
{
 
24
  char *p = _strdup(s);
 
25
  if (!p) {
 
26
    fprintf(stderr, "strdup(%x) failed in gnuw32.c at line %d\n", s, __LINE__);
 
27
    exit(1);
 
28
  }
 
29
  return p;
 
30
}
 
31
 
 
32
void *xmalloc(unsigned size)
 
33
{
 
34
  void *p = malloc(size);
 
35
  if (!p) {
 
36
    fprintf(stderr, "malloc(%d) failed in gnuw32.c at line %d\n", size, __LINE__);
 
37
    exit(1);
 
38
  }
 
39
  return p;
 
40
}
 
41
 
 
42
void *xrealloc(void *p, unsigned size)
 
43
{
 
44
  p = realloc(p, size);
 
45
  if (!p) {
 
46
    fprintf(stderr, "realloc(%d) failed in gnuw32.c at line %d\n", size, __LINE__);
 
47
    exit(1);
 
48
  }
 
49
  return p;
 
50
}
 
51
 
 
52
char *concat(const char *s1,  const char *s2)
 
53
{
 
54
  char *answer = (char *) xmalloc (strlen (s1) + strlen (s2) + 1);
 
55
  strcpy (answer, s1);
 
56
  strcat (answer, s2);
 
57
 
 
58
  return answer;
 
59
}
 
60
 
 
61
char *concat3(const char *s1,  const char *s2,  const char *s3)
 
62
{
 
63
  char *answer
 
64
    = (char *) xmalloc (strlen (s1) + strlen (s2) + strlen (s3) + 1);
 
65
  strcpy (answer, s1);
 
66
  strcat (answer, s2);
 
67
  strcat (answer, s3);
 
68
 
 
69
  return answer;
 
70
}
 
71
 
 
72
char *concatn(const char *str1,  ...)
 
73
{
 
74
  char *arg, *ret;
 
75
  int size = 1;
 
76
  va_list marker;
 
77
 
 
78
  if (!str1)
 
79
    return NULL;
 
80
 
 
81
  size = strlen(str1);
 
82
 
 
83
  va_start(marker, str1);
 
84
  while ((arg = va_arg (marker, char*)) != NULL) {
 
85
    size += strlen(arg);
 
86
  }
 
87
  va_end (marker);
 
88
  
 
89
  
 
90
  ret = xmalloc(size + 1);
 
91
  strcpy(ret, str1);
 
92
  
 
93
  va_start(marker, str1);
 
94
  while ((arg = va_arg (marker, char*)) != NULL) {
 
95
    strcat(ret, arg);
 
96
  }
 
97
  va_end (marker);
 
98
  
 
99
  return ret;
 
100
}