"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/parser.y" between
udunits-2.2.26.tar.gz and udunits-2.2.28.tar.gz

About: UDUNITS supports units of physical quantities. Its C library provides for arithmetic manipulation of units and for conversion of numeric values between compatible units.

parser.y  (udunits-2.2.26):parser.y  (udunits-2.2.28)
%{ %{
/* /*
* Copyright 2013 University Corporation for Atmospheric Research * Copyright 2020 University Corporation for Atmospheric Research. All rights
* reserved.
* *
* This file is part of the UDUNITS-2 package. See the file COPYRIGHT * This file is part of the UDUNITS-2 package. See the file COPYRIGHT
* in the top-level source-directory of the package for copying and * in the top-level source-directory of the package for copying and
* redistribution conditions. * redistribution conditions.
*/ */
/* /*
* bison(1)-based parser for decoding formatted unit specifications. * bison(1)-based parser for decoding formatted unit specifications.
* *
* This module is thread-compatible but not thread-safe. Multi-threaded * This module is thread-compatible but not thread-safe: multi-threaded access
* access must be externally synchronized. * must be externally synchronized.
*/ */
/*LINTLIBRARY*/ /*LINTLIBRARY*/
#ifndef _XOPEN_SOURCE #include "config.h"
# define _XOPEN_SOURCE 500
#endif #include "prefix.h"
#include "udunits2.h"
#include <assert.h> #include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
#ifndef _MSC_VER #include <stdlib.h>
#include <string.h> #include <string.h>
#ifndef _MSC_VER
#include <strings.h> #include <strings.h>
#endif #endif
#include "udunits2.h"
extern int utlex (void);
static ut_unit* _finalUnit; /* fully-parsed specification */ static ut_unit* _finalUnit; /* fully-parsed specification */
static ut_system* _unitSystem; /* The unit-system to use */ static ut_system* _unitSystem; /* The unit-system to use */
static char* _errorMessage; /* last error-message */ static char* _errorMessage; /* last error-message */
static ut_encoding _encoding; /* encoding of string to be parsed */ static ut_encoding _encoding; /* encoding of string to be parsed */
static int _restartScanner;/* restart scanner? */ static int _restartScanner;/* restart scanner? */
static int _isTime; /* product_exp is time? */ static int _isTime; /* product_exp is time? */
/* /*
* Removes leading and trailing whitespace from a string. * Removes leading and trailing whitespace from a string.
skipping to change at line 148 skipping to change at line 152
unsigned hour, minute, second; unsigned hour, minute, second;
if (value < -2400 || value > 2400) if (value < -2400 || value > 2400)
return -1; return -1;
to_clock(value < 0 ? -value : value, &hour, &minute, &second); to_clock(value < 0 ? -value : value, &hour, &minute, &second);
if (hour > 24 || minute >= 60) if (hour > 24 || minute >= 60)
return -1; return -1;
*time = value < 0 *time = (value >= 0)
? ut_encode_clock(-hour, -minute, -second) ? ut_encode_clock(hour, minute, second)
: ut_encode_clock(hour, minute, second); : -ut_encode_clock(hour, minute, second);
return 0; return 0;
} }
/** /**
* Converts an integer value into a time as used by this package. * Converts an integer value into a time as used by this package.
* *
* @param[in] value The integer value. Must correspond to H[H[MM[SS]]]. * @param[in] value The integer value. Must correspond to H[H[MM[SS]]].
* @param[out] time The corresponding time as used by this package. * @param[out] time The corresponding time as used by this package.
* @retval 0 Success. "*time" is set. * @retval 0 Success. "*time" is set.
skipping to change at line 650 skipping to change at line 654
_restartScanner = 1; _restartScanner = 1;
#if YYDEBUG #if YYDEBUG
utdebug = 0; utdebug = 0;
ut_flex_debug = 0; ut_flex_debug = 0;
#endif #endif
_finalUnit = NULL; _finalUnit = NULL;
if (utparse() == 0) { if (utparse() == 0) {
int status; int status;
int n = yy_c_buf_p - buf->yy_ch_buf; ptrdiff_t n = yy_c_buf_p - buf->yy_ch_buf;
if (n >= strlen(utf8String)) { if (n >= strlen(utf8String)) {
unit = _finalUnit; /* success */ unit = _finalUnit; /* success */
status = UT_SUCCESS; status = UT_SUCCESS;
} }
else { else {
/* /*
* Parsing terminated before the end of the string. * Parsing terminated before the end of the string.
*/ */
ut_free(_finalUnit); ut_free(_finalUnit);
 End of changes. 9 change blocks. 
14 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)