~ubuntu-branches/ubuntu/jaunty/glbsp/jaunty

« back to all changes in this revision

Viewing changes to debian/patches/04_sprintf.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Darren Salt
  • Date: 2008-01-30 13:33:49 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080130133349-kgojg33vyiu8xbvp
Tags: 2.24-1
* New upstream release.
* Bumped the lib soname and the library package name due to one silly
  little binary incompatibility caused by changes in an exported struct.
  (Safe; nothing else currently in the archive has ever used libglbsp2.)
* Removed my patches since they're all applied upstream.
* Updated the list of documentation files.
* Build-time changes:
  - Switched from dh_movefiles to dh_install.
  - Updated my makefile to cope with upstream changes.
  - Corrected for debian-rules-ignores-make-clean-error.
  - Corrected for substvar-source-version-is-deprecated.
  - Link libglbsp, rather than glbsp, with libm and libz.
* Fixed shlibdeps. (Closes: #460387)
* Bumped standards version to 3.7.3 (no other changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh /usr/share/dpatch/dpatch-run
2
 
## 04_sprintf.dpatch by  <ds@flibble.youmustbejoking.demon.co.uk>
3
 
##
4
 
## All lines beginning with `## DP:' are a description of the patch.
5
 
## DP: No description.
6
 
 
7
 
@DPATCH@
8
 
diff -urNad glbsp-2.20~/Makefile glbsp-2.20/Makefile
9
 
--- glbsp-2.20~/Makefile        2006-08-13 12:53:45.000000000 +0100
10
 
+++ glbsp-2.20/Makefile 2006-08-13 12:53:46.178842615 +0100
11
 
@@ -9,7 +9,7 @@
12
 
 PROGNAME=glbsp
13
 
 
14
 
 CC=cc
15
 
-CFLAGS=-O2 -Wall -DGLBSP_TEXT -DUNIX -DINLINE_G=inline
16
 
+CFLAGS=-O2 -Wall -DGLBSP_TEXT -DUNIX -DINLINE_G=inline -D_GNU_SOURCE
17
 
 LIBS=-lm -lz
18
 
 
19
 
 OBJS=$(SYSDIR)/main.o     \
20
 
diff -urNad glbsp-2.20~/glbsp.c glbsp-2.20/glbsp.c
21
 
--- glbsp-2.20~/glbsp.c 2006-08-13 12:53:45.000000000 +0100
22
 
+++ glbsp-2.20/glbsp.c  2006-08-13 12:53:46.178842615 +0100
23
 
@@ -42,8 +42,6 @@
24
 
 const nodebuildfuncs_t *cur_funcs = NULL;
25
 
 volatile nodebuildcomms_t *cur_comms = NULL;
26
 
 
27
 
-static char glbsp_message_buf[1024];
28
 
-
29
 
 
30
 
 const nodebuildinfo_t default_buildinfo =
31
 
 {
32
 
@@ -292,8 +290,7 @@
33
 
     // The -hexen option is only kept for backwards compatibility
34
 
     HANDLE_BOOLEAN("hexen", force_hexen)
35
 
 
36
 
-    sprintf(glbsp_message_buf, "Unknown option: %s", argv[0]);
37
 
-    SetErrorMsg(glbsp_message_buf);
38
 
+    SetErrorMsg("Unknown option: %s", argv[0]);
39
 
 
40
 
     cur_comms = NULL;
41
 
     return GLBSP_E_BadArgs;
42
 
@@ -477,7 +474,7 @@
43
 
 glbsp_ret_e GlbspBuildNodes(const nodebuildinfo_t *info,
44
 
     const nodebuildfuncs_t *funcs, volatile nodebuildcomms_t *comms)
45
 
 {
46
 
-  char strbuf[256];
47
 
+  char *strbuf = NULL;
48
 
 
49
 
   glbsp_ret_e ret = GLBSP_E_OK;
50
 
 
51
 
@@ -531,12 +528,14 @@
52
 
   DisplayOpen(DIS_BUILDPROGRESS);
53
 
   DisplaySetTitle("glBSP Build Progress");
54
 
 
55
 
-  sprintf(strbuf, "File: %s", cur_info->input_file);
56
 
+  asprintf(&strbuf, "File: %s", cur_info->input_file);
57
 
  
58
 
   DisplaySetBarText(2, strbuf);
59
 
   DisplaySetBarLimit(2, CountLevels() * 10);
60
 
   DisplaySetBar(2, 0);
61
 
 
62
 
+  free (strbuf);
63
 
+
64
 
   cur_comms->file_pos = 0;
65
 
   
66
 
   // loop over each level in the wad
67
 
diff -urNad glbsp-2.20~/level.c glbsp-2.20/level.c
68
 
--- glbsp-2.20~/level.c 2006-08-13 12:53:45.000000000 +0100
69
 
+++ glbsp-2.20/level.c  2006-08-13 12:53:46.178842615 +0100
70
 
@@ -1524,7 +1524,7 @@
71
 
 //
72
 
 void LoadLevel(void)
73
 
 {
74
 
-  char message[256];
75
 
+  char *message = NULL;
76
 
 
77
 
   const char *level_name = GetLevelName();
78
 
 
79
 
@@ -1536,13 +1536,10 @@
80
 
   // -JL- Identify Hexen mode by presence of BEHAVIOR lump
81
 
   lev_doing_hexen = (FindLevelLump("BEHAVIOR") != NULL);
82
 
 
83
 
-  if (lev_doing_normal)
84
 
-    sprintf(message, "Building normal and GL nodes on %s", level_name);
85
 
-  else
86
 
-    sprintf(message, "Building GL nodes on %s", level_name);
87
 
88
 
-  if (lev_doing_hexen)
89
 
-    strcat(message, " (Hexen)");
90
 
+  asprintf (&message, "Building %sGL nodes on %s%s",
91
 
+            lev_doing_normal ? "normal and " : "",
92
 
+            level_name,
93
 
+            lev_doing_hexen ? " (Hexen)" : "");
94
 
 
95
 
   lev_doing_hexen |= cur_info->force_hexen;
96
 
 
97
 
@@ -1552,6 +1549,8 @@
98
 
   PrintMsg("%s\n", message);
99
 
   PrintVerbose("\n");
100
 
 
101
 
+  free (message);
102
 
+
103
 
   GetVertices();
104
 
   GetSectors();
105
 
   GetSidedefs();
106
 
diff -urNad glbsp-2.20~/system.c glbsp-2.20/system.c
107
 
--- glbsp-2.20~/system.c        2006-08-13 12:53:45.000000000 +0100
108
 
+++ glbsp-2.20/system.c 2006-08-13 12:54:39.759596267 +0100
109
 
@@ -39,8 +39,6 @@
110
 
 static int cpu_big_endian = 0;
111
 
 
112
 
 
113
 
-static char message_buf[1024];
114
 
-
115
 
 #if DEBUG_ENABLED
116
 
 static FILE *debug_fp = NULL;
117
 
 #endif
118
 
@@ -52,12 +50,15 @@
119
 
 void FatalError(const char *str, ...)
120
 
 {
121
 
   va_list args;
122
 
+  char *message_buf = NULL;
123
 
 
124
 
   va_start(args, str);
125
 
-  vsprintf(message_buf, str, args);
126
 
+  vasprintf(&message_buf, str, args);
127
 
   va_end(args);
128
 
 
129
 
   (* cur_funcs->fatal_error)("\nError: *** %s ***\n\n", message_buf);
130
 
+
131
 
+  free (message_buf);
132
 
 }
133
 
 
134
 
 //
135
 
@@ -66,9 +67,10 @@
136
 
 void InternalError(const char *str, ...)
137
 
 {
138
 
   va_list args;
139
 
+  char *message_buf = NULL;
140
 
 
141
 
   va_start(args, str);
142
 
-  vsprintf(message_buf, str, args);
143
 
+  vasprintf(&message_buf, str, args);
144
 
   va_end(args);
145
 
 
146
 
   (* cur_funcs->fatal_error)("\nINTERNAL ERROR: *** %s ***\n\n", message_buf);
147
 
@@ -80,9 +82,10 @@
148
 
 void PrintMsg(const char *str, ...)
149
 
 {
150
 
   va_list args;
151
 
+  char *message_buf = NULL;
152
 
 
153
 
   va_start(args, str);
154
 
-  vsprintf(message_buf, str, args);
155
 
+  vasprintf(&message_buf, str, args);
156
 
   va_end(args);
157
 
 
158
 
   (* cur_funcs->print_msg)("%s", message_buf);
159
 
@@ -98,25 +101,23 @@
160
 
 void PrintVerbose(const char *str, ...)
161
 
 {
162
 
   va_list args;
163
 
+  char *message_buf = NULL;
164
 
 
165
 
-  if (! cur_info->quiet)
166
 
+  if (DEBUG_ENABLED || ! cur_info->quiet)
167
 
   {
168
 
     va_start(args, str);
169
 
-    vsprintf(message_buf, str, args);
170
 
+    vasprintf(&message_buf, str, args);
171
 
     va_end(args);
172
 
+  }
173
 
 
174
 
+  if (! cur_info->quiet)
175
 
     (* cur_funcs->print_msg)("%s", message_buf);
176
 
-  }
177
 
 
178
 
 #if DEBUG_ENABLED
179
 
-  {
180
 
-    va_start(args, str);
181
 
-    vsprintf(message_buf, str, args);
182
 
-    va_end(args);
183
 
-
184
 
-    PrintDebug(">>> %s", message_buf);
185
 
-  }
186
 
+  PrintDebug(">>> %s", message_buf);
187
 
 #endif
188
 
+
189
 
+  free (message_buf);
190
 
 }
191
 
 
192
 
 //
193
 
@@ -125,9 +126,10 @@
194
 
 void PrintWarn(const char *str, ...)
195
 
 {
196
 
   va_list args;
197
 
+  char *message_buf = NULL;
198
 
 
199
 
   va_start(args, str);
200
 
-  vsprintf(message_buf, str, args);
201
 
+  vasprintf(&message_buf, str, args);
202
 
   va_end(args);
203
 
 
204
 
   (* cur_funcs->print_msg)("Warning: %s", message_buf);
205
 
@@ -137,6 +139,8 @@
206
 
 #if DEBUG_ENABLED
207
 
   PrintDebug("Warning: %s", message_buf);
208
 
 #endif
209
 
+
210
 
+  free (message_buf);
211
 
 }
212
 
 
213
 
 //
214
 
@@ -145,35 +149,43 @@
215
 
 void PrintMiniWarn(const char *str, ...)
216
 
 {
217
 
   va_list args;
218
 
+  char *message_buf = NULL;
219
 
 
220
 
-  if (cur_info->mini_warnings)
221
 
+  if (DEBUG_ENABLED || cur_info->mini_warnings)
222
 
   {
223
 
     va_start(args, str);
224
 
-    vsprintf(message_buf, str, args);
225
 
+    vasprintf(&message_buf, str, args);
226
 
     va_end(args);
227
 
+  }
228
 
 
229
 
+  if (cur_info->mini_warnings)
230
 
     (* cur_funcs->print_msg)("Warning: %s", message_buf);
231
 
-  }
232
 
 
233
 
   cur_comms->total_small_warn++;
234
 
 
235
 
 #if DEBUG_ENABLED
236
 
-  va_start(args, str);
237
 
-  vsprintf(message_buf, str, args);
238
 
-  va_end(args);
239
 
-
240
 
   PrintDebug("MiniWarn: %s", message_buf);
241
 
 #endif
242
 
+
243
 
+  free (message_buf);
244
 
 }
245
 
 
246
 
 //
247
 
 // SetErrorMsg
248
 
 //
249
 
-void SetErrorMsg(const char *str)
250
 
+void SetErrorMsg(const char *str, ...)
251
 
 {
252
 
   GlbspFree(cur_comms->message);
253
 
-
254
 
-  cur_comms->message = GlbspStrDup(str);
255
 
+  cur_comms->message = NULL;
256
 
+  if (str)
257
 
+  {
258
 
+    va_list args;
259
 
+    char *message = NULL;
260
 
+    va_start(args, str);
261
 
+    vasprintf (&message, str, args);
262
 
+    cur_comms->message = message;
263
 
+    va_end(args);
264
 
+  }
265
 
 }
266
 
 
267
 
 
268
 
diff -urNad glbsp-2.20~/system.h glbsp-2.20/system.h
269
 
--- glbsp-2.20~/system.h        2006-08-13 12:53:45.000000000 +0100
270
 
+++ glbsp-2.20/system.h 2006-08-13 12:53:46.178842615 +0100
271
 
@@ -56,7 +56,7 @@
272
 
 void PrintMiniWarn(const char *str, ...) __attribute__ ((format (printf, 1, 2)));
273
 
 
274
 
 // set message for certain errors
275
 
-void SetErrorMsg(const char *str);
276
 
+void SetErrorMsg(const char *str, ...) __attribute__ ((format (printf, 1, 2)));
277
 
 
278
 
 // endian handling
279
 
 void InitEndian(void);
280
 
diff -urNad glbsp-2.20~/util.c glbsp-2.20/util.c
281
 
--- glbsp-2.20~/util.c  2006-08-13 12:53:45.000000000 +0100
282
 
+++ glbsp-2.20/util.c   2006-08-13 12:53:46.178842615 +0100
283
 
@@ -209,7 +209,7 @@
284
 
 
285
 
   GetSystemTime(&sys_time);
286
 
 
287
 
-  sprintf(str_buf, "%04d-%02d-%02d %02d:%02d:%02d.%04d",
288
 
+  snprintf(str_buf, sizeof(str_buf), "%04d-%02d-%02d %02d:%02d:%02d.%04d",
289
 
       sys_time.wYear, sys_time.wMonth, sys_time.wDay,
290
 
       sys_time.wHour, sys_time.wMinute, sys_time.wSecond,
291
 
       sys_time.wMilliseconds * 10);
292
 
@@ -230,7 +230,7 @@
293
 
   if (! calend_time)
294
 
     return NULL;
295
 
 
296
 
-  sprintf(str_buf, "%04d-%02d-%02d %02d:%02d:%02d.%04d",
297
 
+  snprintf(str_buf, sizeof(str_buf), "%04d-%02d-%02d %02d:%02d:%02d.%04d",
298
 
       calend_time->tm_year + 1900, calend_time->tm_mon + 1,
299
 
       calend_time->tm_mday,
300
 
       calend_time->tm_hour, calend_time->tm_min,
301
 
diff -urNad glbsp-2.20~/wad.c glbsp-2.20/wad.c
302
 
--- glbsp-2.20~/wad.c   2006-08-13 12:53:45.000000000 +0100
303
 
+++ glbsp-2.20/wad.c    2006-08-13 12:53:46.178842615 +0100
304
 
@@ -260,25 +260,20 @@
305
 
 {
306
 
   size_t len;
307
 
   raw_wad_header_t header;
308
 
-  char strbuf[1024];
309
 
 
310
 
   len = fread(&header, sizeof(header), 1, in_file);
311
 
 
312
 
   if (len != 1)
313
 
   {
314
 
-    sprintf(strbuf, "Trouble reading wad header for %s [%s]", 
315
 
+    SetErrorMsg("Trouble reading wad header for %s [%s]", 
316
 
       filename, strerror(errno));
317
 
-
318
 
-    SetErrorMsg(strbuf);
319
 
     return FALSE;
320
 
   }
321
 
 
322
 
   if (! CheckMagic(header.type))
323
 
   {
324
 
-    sprintf(strbuf, "%s does not appear to be a wad file (bad magic)", 
325
 
+    SetErrorMsg("%s does not appear to be a wad file (bad magic)", 
326
 
         filename);
327
 
-
328
 
-    SetErrorMsg(strbuf);
329
 
     return FALSE;
330
 
   }
331
 
 
332
 
@@ -694,7 +689,7 @@
333
 
 
334
 
   if (strlen(level->name) <= 5)
335
 
   {
336
 
-    sprintf(name_buf, "GL_%s", level->name);
337
 
+    snprintf(name_buf, sizeof(name_buf), "GL_%s", level->name);
338
 
   }
339
 
   else
340
 
   {
341
 
@@ -1014,21 +1009,15 @@
342
 
 //
343
 
 char *ReplaceExtension(const char *filename, const char *ext)
344
 
 {
345
 
-  char *dot_pos;
346
 
-  char buffer[512];
347
 
+  char *buffer;
348
 
+  const char *dot_pos = strrchr (filename, '.');
349
 
 
350
 
-  strcpy(buffer, filename);
351
 
-  
352
 
-  dot_pos = strrchr(buffer, '.');
353
 
+  if (!dot_pos)
354
 
+    dot_pos = filename + strlen (filename);
355
 
 
356
 
-  if (dot_pos)
357
 
-    dot_pos[1] = 0;
358
 
-  else
359
 
-    strcat(buffer, ".");
360
 
-  
361
 
-  strcat(buffer, ext);
362
 
+  asprintf (&buffer, "%.*s.%s", (int)(dot_pos - filename), filename, ext);
363
 
 
364
 
-  return UtilStrDup(buffer);
365
 
+  return buffer;
366
 
 }
367
 
 
368
 
 
369
 
@@ -1270,7 +1259,7 @@
370
 
 glbsp_ret_e ReadWadFile(const char *filename)
371
 
 {
372
 
   int check;
373
 
-  char strbuf[1024];
374
 
+  char *strbuf = NULL;
375
 
 
376
 
   // open input wad file & read header
377
 
   in_file = fopen(filename, "rb");
378
 
@@ -1278,13 +1267,11 @@
379
 
   if (! in_file)
380
 
   {
381
 
     if (errno == ENOENT)
382
 
-      sprintf(strbuf, "Cannot open WAD file: %s", filename); 
383
 
+      SetErrorMsg("Cannot open WAD file: %s", filename); 
384
 
     else
385
 
-      sprintf(strbuf, "Cannot open WAD file: %s [%s]", filename, 
386
 
+      SetErrorMsg("Cannot open WAD file: %s [%s]", filename, 
387
 
           strerror(errno));
388
 
 
389
 
-    SetErrorMsg(strbuf);
390
 
-
391
 
     return GLBSP_E_ReadError;
392
 
   }
393
 
   
394
 
@@ -1305,12 +1292,14 @@
395
 
   DisplayOpen(DIS_FILEPROGRESS);
396
 
   DisplaySetTitle("glBSP Reading Wad");
397
 
   
398
 
-  sprintf(strbuf, "Reading: %s", filename);
399
 
+  asprintf(&strbuf, "Reading: %s", filename);
400
 
 
401
 
   DisplaySetBarText(1, strbuf);
402
 
   DisplaySetBarLimit(1, CountLumpTypes(LUMP_READ_ME, LUMP_READ_ME));
403
 
   DisplaySetBar(1, 0);
404
 
 
405
 
+  free (strbuf);
406
 
+
407
 
   cur_comms->file_pos = 0;
408
 
 
409
 
   // now read lumps
410
 
@@ -1334,7 +1323,7 @@
411
 
 glbsp_ret_e WriteWadFile(const char *filename)
412
 
 {
413
 
   int check1, check2;
414
 
-  char strbuf[1024];
415
 
+  char *strbuf = NULL;
416
 
 
417
 
   PrintMsg("\n");
418
 
   PrintMsg("Saving WAD as %s\n", filename);
419
 
@@ -1349,11 +1338,9 @@
420
 
 
421
 
   if (! out_file)
422
 
   {
423
 
-    sprintf(strbuf, "Cannot create WAD file: %s [%s]", filename,
424
 
+    SetErrorMsg("Cannot create WAD file: %s [%s]", filename,
425
 
         strerror(errno));
426
 
 
427
 
-    SetErrorMsg(strbuf);
428
 
-
429
 
     return GLBSP_E_WriteError;
430
 
   }
431
 
 
432
 
@@ -1362,12 +1349,14 @@
433
 
   DisplayOpen(DIS_FILEPROGRESS);
434
 
   DisplaySetTitle("glBSP Writing Wad");
435
 
   
436
 
-  sprintf(strbuf, "Writing: %s", filename);
437
 
+  asprintf(&strbuf, "Writing: %s", filename);
438
 
 
439
 
   DisplaySetBarText(1, strbuf);
440
 
   DisplaySetBarLimit(1, CountLumpTypes(LUMP_IGNORE_ME, 0));
441
 
   DisplaySetBar(1, 0);
442
 
 
443
 
+  free (strbuf);
444
 
+
445
 
   cur_comms->file_pos = 0;
446
 
 
447
 
   // now write all the lumps to the output wad