~ubuntu-branches/ubuntu/natty/pymca/natty

« back to all changes in this revision

Viewing changes to PyMca/specfile/src/sfmca.c

  • Committer: Bazaar Package Importer
  • Author(s): Angel Abad
  • Date: 2010-11-18 22:28:16 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20101118222816-b8g5f3bmjp97cckq
Tags: 4.4.0-2ubuntu1
* Merge from debian unstable (LP: #677221). Remaining changes:
  - rm -f the data files from the pymca package instead of rm. fix FTBFS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#/*##########################################################################
2
 
# Copyright (C) 2004-2007 European Synchrotron Radiation Facility
 
2
# Copyright (C) 2004-2010 European Synchrotron Radiation Facility
3
3
#
4
4
# This file is part of the PyMCA X-ray Fluorescence Toolkit developed at
5
5
# the ESRF by the Beamline Instrumentation Software Support (BLISS) group.
22
22
# and cannot be used as a free plugin for a non-free program. 
23
23
#
24
24
# Please contact the ESRF industrial unit (industry@esrf.fr) if this license 
25
 
# is a problem to you.
 
25
# is a problem for you.
26
26
#############################################################################*/
27
27
/*char RcsId[] = "$Header: /segfs/bliss/source/python/specfile/specfile-3.1/src/RCS/sfmca.c,v 1.3 2002/11/15 16:25:44 sole Exp $"; */
28
28
/************************************************************************
61
61
 */
62
62
#include <SpecFile.h>
63
63
#include <SpecFileP.h>
 
64
#include <locale_management.h>
 
65
#ifndef _GNU_SOURCE
 
66
#ifdef PYMCA_POSIX
 
67
#include <locale.h>
 
68
#endif
 
69
#endif
64
70
 
65
71
#include <ctype.h>
66
72
#include <stdlib.h>
163
169
 
164
170
     long    blocks=1, 
165
171
             initsize=1024;
166
 
 
 
172
#ifndef _GNU_SOURCE
 
173
#ifdef PYMCA_POSIX
 
174
        char *currentLocaleBuffer;
 
175
        char localeBuffer[21];
 
176
#endif
 
177
#endif
167
178
 
168
179
     headersize = ((SpecScan *)sf->current->contents)->data_offset
169
180
                - ((SpecScan *)sf->current->contents)->offset;
249
260
    /*
250
261
     * continue
251
262
     */
 
263
#ifndef _GNU_SOURCE
 
264
#ifdef PYMCA_POSIX
 
265
        currentLocaleBuffer = setlocale(LC_NUMERIC, NULL);
 
266
        strcpy(localeBuffer, currentLocaleBuffer);
 
267
        setlocale(LC_NUMERIC, "C\0");
 
268
#endif
 
269
#endif
252
270
     for ( ;(*(ptr+1) != '\n' || (*ptr == MCA_CONT)) && ptr < to - 1 ; ptr++)
253
271
     { 
254
272
         if (*ptr == ' ' || *ptr == '\t' || *ptr == '\\' || *ptr == '\n') {
258
276
                    if ((data = (double *)realloc (data, sizeof(double) * blocks * initsize)) 
259
277
                                       == (double *)NULL) {
260
278
                          *error = SF_ERR_MEMORY_ALLOC;
261
 
                          return(-1);
 
279
#ifndef _GNU_SOURCE
 
280
#ifdef PYMCA_POSIX
 
281
        setlocale(LC_NUMERIC, localeBuffer);
 
282
#endif
 
283
#endif
 
284
                                                        return(-1);
262
285
                    }
263
286
 
264
287
                }
265
288
                strval[i] = '\0';
266
289
                i = 0;
267
 
                val = atof(strval);
 
290
                val = PyMcaAtof(strval);
268
291
                data[vals] = val;
269
292
                vals++;
270
293
             }
272
295
             strval[i] = *ptr;
273
296
             i++;
274
297
         }
275
 
     }
 
298
         }
276
299
 
277
300
     if (isnumber(*ptr)) {
278
301
       strval[i]    = *ptr;
279
302
       strval[i+1]  = '\0';
280
 
       val = atof(strval);
 
303
       val = PyMcaAtof(strval);
281
304
       data[vals] = val;
282
305
       vals++;
283
306
     }
 
307
#ifndef _GNU_SOURCE
 
308
#ifdef PYMCA_POSIX
 
309
        setlocale(LC_NUMERIC, localeBuffer);
 
310
#endif
 
311
#endif
284
312
 
285
313
    *retdata = data;
286
314