mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Core: introduce new subsurface-string header
First small step to shrinking dive.h. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									c71a5d7413
								
							
						
					
					
						commit
						d577467f97
					
				
					 53 changed files with 140 additions and 68 deletions
				
			
		|  | @ -11,6 +11,7 @@ | ||||||
| #include "gettext.h" | #include "gettext.h" | ||||||
| #include "datatrak.h" | #include "datatrak.h" | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "units.h" | #include "units.h" | ||||||
| #include "device.h" | #include "device.h" | ||||||
| #include "file.h" | #include "file.h" | ||||||
|  |  | ||||||
|  | @ -20,6 +20,7 @@ | ||||||
| #include <math.h> | #include <math.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include <assert.h> | #include <assert.h> | ||||||
| #include "core/planner.h" | #include "core/planner.h" | ||||||
| #include "qthelper.h" | #include "qthelper.h" | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| // SPDX-License-Identifier: GPL-2.0
 | // SPDX-License-Identifier: GPL-2.0
 | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "device.h" | #include "device.h" | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  |  | ||||||
|  | @ -7,6 +7,7 @@ | ||||||
| #include <limits.h> | #include <limits.h> | ||||||
| #include "gettext.h" | #include "gettext.h" | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "libdivecomputer.h" | #include "libdivecomputer.h" | ||||||
| #include "device.h" | #include "device.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
|  |  | ||||||
							
								
								
									
										66
									
								
								core/dive.h
									
										
									
									
									
								
							
							
						
						
									
										66
									
								
								core/dive.h
									
										
									
									
									
								
							|  | @ -2,6 +2,8 @@ | ||||||
| #ifndef DIVE_H | #ifndef DIVE_H | ||||||
| #define DIVE_H | #define DIVE_H | ||||||
| 
 | 
 | ||||||
|  | // dive and dive computer related structures and helpers
 | ||||||
|  | 
 | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <stdint.h> | #include <stdint.h> | ||||||
| #include <stdbool.h> | #include <stdbool.h> | ||||||
|  | @ -13,56 +15,6 @@ | ||||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||||
| #include "divesite.h" | #include "divesite.h" | ||||||
| 
 | 
 | ||||||
| /* Windows has no MIN/MAX macros - so let's just roll our own */ |  | ||||||
| #define MIN(x, y) ({                \ |  | ||||||
| 	__typeof__(x) _min1 = (x);          \ |  | ||||||
| 	__typeof__(y) _min2 = (y);          \ |  | ||||||
| 	(void) (&_min1 == &_min2);      \ |  | ||||||
| 	_min1 < _min2 ? _min1 : _min2; }) |  | ||||||
| 
 |  | ||||||
| #define MAX(x, y) ({                \ |  | ||||||
| 	__typeof__(x) _max1 = (x);          \ |  | ||||||
| 	__typeof__(y) _max2 = (y);          \ |  | ||||||
| 	(void) (&_max1 == &_max2);      \ |  | ||||||
| 	_max1 > _max2 ? _max1 : _max2; }) |  | ||||||
| 
 |  | ||||||
| #define IS_FP_SAME(_a, _b) (fabs((_a) - (_b)) <= 0.000001 * MAX(fabs(_a), fabs(_b))) |  | ||||||
| 
 |  | ||||||
| static inline bool same_string(const char *a, const char *b) |  | ||||||
| { |  | ||||||
| 	return !strcmp(a ?: "", b ?: ""); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline bool same_string_caseinsensitive(const char *a, const char *b) |  | ||||||
| { |  | ||||||
| 	return !strcasecmp(a ?: "", b ?: ""); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline bool empty_string(const char *s) |  | ||||||
| { |  | ||||||
| 	return !s || !*s; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline bool includes_string_caseinsensitive(const char *haystack, const char *needle) |  | ||||||
| { |  | ||||||
| 	if (!needle) |  | ||||||
| 		return 1; /* every string includes the NULL string */ |  | ||||||
| 	if (!haystack) |  | ||||||
| 		return 0; /* nothing is included in the NULL string */ |  | ||||||
| 	int len = strlen(needle); |  | ||||||
| 	while (*haystack) { |  | ||||||
| 		if (strncasecmp(haystack, needle, len)) |  | ||||||
| 			return 1; |  | ||||||
| 		haystack++; |  | ||||||
| 	} |  | ||||||
| 	return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline char *copy_string(const char *s) |  | ||||||
| { |  | ||||||
| 	return (s && *s) ? strdup(s) : NULL; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| #include <libxml/tree.h> | #include <libxml/tree.h> | ||||||
| #include <libxslt/transform.h> | #include <libxslt/transform.h> | ||||||
| #include <libxslt/xsltutils.h> | #include <libxslt/xsltutils.h> | ||||||
|  | @ -1000,25 +952,13 @@ extern void reset_cylinders(struct dive *dive, bool track_gas); | ||||||
| extern void dump_cylinders(struct dive *dive, bool verbose); | extern void dump_cylinders(struct dive *dive, bool verbose); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| /*
 |  | ||||||
|  * String handling. |  | ||||||
|  */ |  | ||||||
| #define STRTOD_NO_SIGN 0x01 |  | ||||||
| #define STRTOD_NO_DOT 0x02 |  | ||||||
| #define STRTOD_NO_COMMA 0x04 |  | ||||||
| #define STRTOD_NO_EXPONENT 0x08 |  | ||||||
| extern double strtod_flags(const char *str, const char **ptr, unsigned int flags); |  | ||||||
| 
 |  | ||||||
| #define STRTOD_ASCII (STRTOD_NO_COMMA) |  | ||||||
| 
 |  | ||||||
| #define ascii_strtod(str, ptr) strtod_flags(str, ptr, STRTOD_ASCII) |  | ||||||
| 
 |  | ||||||
| extern void set_userid(const char *user_id); | extern void set_userid(const char *user_id); | ||||||
| extern void set_informational_units(const char *units); | extern void set_informational_units(const char *units); | ||||||
| extern void set_git_prefs(const char *prefs); | extern void set_git_prefs(const char *prefs); | ||||||
| 
 | 
 | ||||||
| extern char *get_dive_date_c_string(timestamp_t when); | extern char *get_dive_date_c_string(timestamp_t when); | ||||||
| extern void update_setpoint_events(struct dive *dive, struct divecomputer *dc); | extern void update_setpoint_events(struct dive *dive, struct divecomputer *dc); | ||||||
|  | 
 | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| // SPDX-License-Identifier: GPL-2.0
 | // SPDX-License-Identifier: GPL-2.0
 | ||||||
| #include "divecomputer.h" | #include "divecomputer.h" | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "subsurface-qt/SettingsObjectWrapper.h" | #include "subsurface-qt/SettingsObjectWrapper.h" | ||||||
| 
 | 
 | ||||||
| DiveComputerList dcList; | DiveComputerList dcList; | ||||||
|  |  | ||||||
|  | @ -41,6 +41,7 @@ | ||||||
| #include <libxslt/transform.h> | #include <libxslt/transform.h> | ||||||
| 
 | 
 | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
| #include "display.h" | #include "display.h" | ||||||
| #include "planner.h" | #include "planner.h" | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ | ||||||
| /* divesite.c */ | /* divesite.c */ | ||||||
| #include "divesite.h" | #include "divesite.h" | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
| #include "membuffer.h" | #include "membuffer.h" | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -6,6 +6,7 @@ | ||||||
| #include "divesitehelpers.h" | #include "divesitehelpers.h" | ||||||
| 
 | 
 | ||||||
| #include "divesite.h" | #include "divesite.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "helpers.h" | #include "helpers.h" | ||||||
| #include "membuffer.h" | #include "membuffer.h" | ||||||
| #include <QDebug> | #include <QDebug> | ||||||
|  |  | ||||||
|  | @ -10,6 +10,7 @@ | ||||||
| #include <time.h> | #include <time.h> | ||||||
| 
 | 
 | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
| #include "file.h" | #include "file.h" | ||||||
| #include "git-access.h" | #include "git-access.h" | ||||||
|  |  | ||||||
|  | @ -17,6 +17,7 @@ | ||||||
| #include <git2.h> | #include <git2.h> | ||||||
| 
 | 
 | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "membuffer.h" | #include "membuffer.h" | ||||||
| #include "strndup.h" | #include "strndup.h" | ||||||
| #include "qthelper.h" | #include "qthelper.h" | ||||||
|  |  | ||||||
|  | @ -5,6 +5,7 @@ | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "parse.h" | #include "parse.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
| #include "device.h" | #include "device.h" | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ | ||||||
| #include <libdivecomputer/parser.h> | #include <libdivecomputer/parser.h> | ||||||
| 
 | 
 | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
| #include "file.h" | #include "file.h" | ||||||
| #include "parse.h" | #include "parse.h" | ||||||
|  |  | ||||||
|  | @ -5,6 +5,7 @@ | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "parse.h" | #include "parse.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
| #include "device.h" | #include "device.h" | ||||||
|  |  | ||||||
|  | @ -5,6 +5,7 @@ | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "parse.h" | #include "parse.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
| #include "device.h" | #include "device.h" | ||||||
|  |  | ||||||
|  | @ -5,6 +5,7 @@ | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "parse.h" | #include "parse.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
| #include "device.h" | #include "device.h" | ||||||
|  |  | ||||||
|  | @ -13,6 +13,7 @@ | ||||||
| #include <fcntl.h> | #include <fcntl.h> | ||||||
| #include "gettext.h" | #include "gettext.h" | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "device.h" | #include "device.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
| #include "display.h" | #include "display.h" | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ | ||||||
| /* linux.c */ | /* linux.c */ | ||||||
| /* implements Linux specific functions */ | /* implements Linux specific functions */ | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "display.h" | #include "display.h" | ||||||
| #include "membuffer.h" | #include "membuffer.h" | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
|  | @ -20,6 +20,7 @@ | ||||||
| #include "gettext.h" | #include "gettext.h" | ||||||
| 
 | 
 | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
| #include "device.h" | #include "device.h" | ||||||
| #include "membuffer.h" | #include "membuffer.h" | ||||||
|  |  | ||||||
|  | @ -5,6 +5,7 @@ | ||||||
| #include <dirent.h> | #include <dirent.h> | ||||||
| #include <fnmatch.h> | #include <fnmatch.h> | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "display.h" | #include "display.h" | ||||||
| #include <CoreFoundation/CoreFoundation.h> | #include <CoreFoundation/CoreFoundation.h> | ||||||
| #if !defined(__IPHONE_5_0) | #if !defined(__IPHONE_5_0) | ||||||
|  |  | ||||||
|  | @ -4,6 +4,7 @@ | ||||||
| #include <string.h> | #include <string.h> | ||||||
| 
 | 
 | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "gettext.h" | #include "gettext.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
| #include "libdivecomputer.h" | #include "libdivecomputer.h" | ||||||
|  |  | ||||||
|  | @ -22,6 +22,7 @@ | ||||||
| #include "gettext.h" | #include "gettext.h" | ||||||
| 
 | 
 | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "parse.h" | #include "parse.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
| #include "device.h" | #include "device.h" | ||||||
|  |  | ||||||
|  | @ -7,6 +7,7 @@ | ||||||
| #include <libdivecomputer/parser.h> | #include <libdivecomputer/parser.h> | ||||||
| 
 | 
 | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "parse.h" | #include "parse.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
| #include "device.h" | #include "device.h" | ||||||
|  |  | ||||||
|  | @ -10,6 +10,7 @@ | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "deco.h" | #include "deco.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
| #include "planner.h" | #include "planner.h" | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ | ||||||
| #define PREFSMACROS_H | #define PREFSMACROS_H | ||||||
| 
 | 
 | ||||||
| #include "core/qthelper.h" | #include "core/qthelper.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| 
 | 
 | ||||||
| #define SB(V, B) s.setValue(V, (int)(B->isChecked() ? 1 : 0)) | #define SB(V, B) s.setValue(V, (int)(B->isChecked() ? 1 : 0)) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -8,6 +8,7 @@ | ||||||
| #include <assert.h> | #include <assert.h> | ||||||
| 
 | 
 | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "display.h" | #include "display.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -17,6 +17,7 @@ | ||||||
| #include "libdivecomputer.h" | #include "libdivecomputer.h" | ||||||
| #include "core/qt-ble.h" | #include "core/qt-ble.h" | ||||||
| #include "core/btdiscovery.h" | #include "core/btdiscovery.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| 
 | 
 | ||||||
| #define BLE_TIMEOUT 12000 // 12 seconds seems like a very long time to wait
 | #define BLE_TIMEOUT 12000 // 12 seconds seems like a very long time to wait
 | ||||||
| #define DEBUG_THRESHOLD 50 | #define DEBUG_THRESHOLD 50 | ||||||
|  |  | ||||||
|  | @ -1,6 +1,8 @@ | ||||||
| // SPDX-License-Identifier: GPL-2.0
 | // SPDX-License-Identifier: GPL-2.0
 | ||||||
| #include "qthelper.h" | #include "qthelper.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "helpers.h" | #include "helpers.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "gettextfromc.h" | #include "gettextfromc.h" | ||||||
| #include "statistics.h" | #include "statistics.h" | ||||||
| #include "membuffer.h" | #include "membuffer.h" | ||||||
|  |  | ||||||
|  | @ -17,6 +17,7 @@ | ||||||
| #include <git2.h> | #include <git2.h> | ||||||
| 
 | 
 | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
| #include "device.h" | #include "device.h" | ||||||
| #include "membuffer.h" | #include "membuffer.h" | ||||||
|  |  | ||||||
|  | @ -14,6 +14,7 @@ | ||||||
| #include <fcntl.h> | #include <fcntl.h> | ||||||
| 
 | 
 | ||||||
| #include "dive.h" | #include "dive.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
| #include "device.h" | #include "device.h" | ||||||
| #include "membuffer.h" | #include "membuffer.h" | ||||||
|  |  | ||||||
|  | @ -28,7 +28,7 @@ | ||||||
|  * they have locales with commas", just pass in a zero flag. |  * they have locales with commas", just pass in a zero flag. | ||||||
|  */ |  */ | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
| #include "dive.h" | #include "subsurface-string.h" | ||||||
| 
 | 
 | ||||||
| double strtod_flags(const char *str, const char **ptr, unsigned int flags) | double strtod_flags(const char *str, const char **ptr, unsigned int flags) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -4,9 +4,10 @@ | ||||||
| #include <QDateTime> | #include <QDateTime> | ||||||
| #include <QTextDocument> | #include <QTextDocument> | ||||||
| 
 | 
 | ||||||
| #include "../qthelper.h" | #include "core/qthelper.h" | ||||||
| #include "../helpers.h" | #include "core/helpers.h" | ||||||
| #include "../../qt-models/tankinfomodel.h" | #include "core/subsurface-string.h" | ||||||
|  | #include "qt-models/tankinfomodel.h" | ||||||
| 
 | 
 | ||||||
| static QString EMPTY_DIVE_STRING = QStringLiteral(""); | static QString EMPTY_DIVE_STRING = QStringLiteral(""); | ||||||
| enum returnPressureSelector {START_PRESSURE, END_PRESSURE}; | enum returnPressureSelector {START_PRESSURE, END_PRESSURE}; | ||||||
|  |  | ||||||
							
								
								
									
										81
									
								
								core/subsurface-string.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								core/subsurface-string.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,81 @@ | ||||||
|  | // SPDX-License-Identifier: GPL-2.0
 | ||||||
|  | #ifndef SUBSURFACE_STRING_H | ||||||
|  | #define SUBSURFACE_STRING_H | ||||||
|  | 
 | ||||||
|  | #include <stdbool.h> | ||||||
|  | #include <string.h> | ||||||
|  | #include <time.h> | ||||||
|  | 
 | ||||||
|  | // shared generic definitions and macros
 | ||||||
|  | // mostly about strings, but a couple of math macros are here as well
 | ||||||
|  | 
 | ||||||
|  | /* Windows has no MIN/MAX macros - so let's just roll our own */ | ||||||
|  | #define MIN(x, y) ({                \ | ||||||
|  | 	__typeof__(x) _min1 = (x);          \ | ||||||
|  | 	__typeof__(y) _min2 = (y);          \ | ||||||
|  | 	(void) (&_min1 == &_min2);      \ | ||||||
|  | 	_min1 < _min2 ? _min1 : _min2; }) | ||||||
|  | 
 | ||||||
|  | #define MAX(x, y) ({                \ | ||||||
|  | 	__typeof__(x) _max1 = (x);          \ | ||||||
|  | 	__typeof__(y) _max2 = (y);          \ | ||||||
|  | 	(void) (&_max1 == &_max2);      \ | ||||||
|  | 	_max1 > _max2 ? _max1 : _max2; }) | ||||||
|  | 
 | ||||||
|  | #define IS_FP_SAME(_a, _b) (fabs((_a) - (_b)) <= 0.000001 * MAX(fabs(_a), fabs(_b))) | ||||||
|  | 
 | ||||||
|  | // string handling
 | ||||||
|  | 
 | ||||||
|  | #ifdef __cplusplus | ||||||
|  | extern "C" { | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | static inline bool same_string(const char *a, const char *b) | ||||||
|  | { | ||||||
|  | 	return !strcmp(a ?: "", b ?: ""); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline bool same_string_caseinsensitive(const char *a, const char *b) | ||||||
|  | { | ||||||
|  | 	return !strcasecmp(a ?: "", b ?: ""); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline bool empty_string(const char *s) | ||||||
|  | { | ||||||
|  | 	return !s || !*s; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline bool includes_string_caseinsensitive(const char *haystack, const char *needle) | ||||||
|  | { | ||||||
|  | 	if (!needle) | ||||||
|  | 		return 1; /* every string includes the NULL string */ | ||||||
|  | 	if (!haystack) | ||||||
|  | 		return 0; /* nothing is included in the NULL string */ | ||||||
|  | 	int len = strlen(needle); | ||||||
|  | 	while (*haystack) { | ||||||
|  | 		if (strncasecmp(haystack, needle, len)) | ||||||
|  | 			return 1; | ||||||
|  | 		haystack++; | ||||||
|  | 	} | ||||||
|  | 	return 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline char *copy_string(const char *s) | ||||||
|  | { | ||||||
|  | 	return (s && *s) ? strdup(s) : NULL; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #define STRTOD_NO_SIGN 0x01 | ||||||
|  | #define STRTOD_NO_DOT 0x02 | ||||||
|  | #define STRTOD_NO_COMMA 0x04 | ||||||
|  | #define STRTOD_NO_EXPONENT 0x08 | ||||||
|  | extern double strtod_flags(const char *str, const char **ptr, unsigned int flags); | ||||||
|  | 
 | ||||||
|  | #define STRTOD_ASCII (STRTOD_NO_COMMA) | ||||||
|  | 
 | ||||||
|  | #define ascii_strtod(str, ptr) strtod_flags(str, ptr, STRTOD_ASCII) | ||||||
|  | 
 | ||||||
|  | #ifdef __cplusplus | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  | #endif // SUBSURFACE_STRING_H
 | ||||||
|  | @ -1,5 +1,6 @@ | ||||||
| // SPDX-License-Identifier: GPL-2.0
 | // SPDX-License-Identifier: GPL-2.0
 | ||||||
| #include "subsurfacestartup.h" | #include "subsurfacestartup.h" | ||||||
|  | #include "subsurface-string.h" | ||||||
| #include "version.h" | #include "version.h" | ||||||
| #include <stdbool.h> | #include <stdbool.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
|  | @ -24,6 +24,7 @@ | ||||||
| #include "libdivecomputer.h" | #include "libdivecomputer.h" | ||||||
| #include "uemis.h" | #include "uemis.h" | ||||||
| #include "divelist.h" | #include "divelist.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| 
 | 
 | ||||||
| #define ERR_FS_ALMOST_FULL QT_TRANSLATE_NOOP("gettextFromC", "Uemis Zurich: the file system is almost full.\nDisconnect/reconnect the dive computer\nand click \'Retry\'") | #define ERR_FS_ALMOST_FULL QT_TRANSLATE_NOOP("gettextFromC", "Uemis Zurich: the file system is almost full.\nDisconnect/reconnect the dive computer\nand click \'Retry\'") | ||||||
| #define ERR_FS_FULL QT_TRANSLATE_NOOP("gettextFromC", "Uemis Zurich: the file system is full.\nDisconnect/reconnect the dive computer\nand click Retry") | #define ERR_FS_FULL QT_TRANSLATE_NOOP("gettextFromC", "Uemis Zurich: the file system is full.\nDisconnect/reconnect the dive computer\nand click Retry") | ||||||
|  |  | ||||||
|  | @ -4,6 +4,7 @@ | ||||||
| #include "desktop-widgets/mainwindow.h" | #include "desktop-widgets/mainwindow.h" | ||||||
| #include "desktop-widgets/divelistview.h" | #include "desktop-widgets/divelistview.h" | ||||||
| #include "core/display.h" | #include "core/display.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| #include "core/uemis.h" | #include "core/uemis.h" | ||||||
| #include "core/subsurface-qt/SettingsObjectWrapper.h" | #include "core/subsurface-qt/SettingsObjectWrapper.h" | ||||||
| #include "qt-models/models.h" | #include "qt-models/models.h" | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| // SPDX-License-Identifier: GPL-2.0
 | // SPDX-License-Identifier: GPL-2.0
 | ||||||
| #include "desktop-widgets/locationinformation.h" | #include "desktop-widgets/locationinformation.h" | ||||||
| #include "core/dive.h" | #include "core/dive.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| #include "desktop-widgets/mainwindow.h" | #include "desktop-widgets/mainwindow.h" | ||||||
| #include "desktop-widgets/divelistview.h" | #include "desktop-widgets/divelistview.h" | ||||||
| #include "core/qthelper.h" | #include "core/qthelper.h" | ||||||
|  |  | ||||||
|  | @ -15,6 +15,7 @@ | ||||||
| #include <QStatusBar> | #include <QStatusBar> | ||||||
| 
 | 
 | ||||||
| #include "core/version.h" | #include "core/version.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| #include "desktop-widgets/divelistview.h" | #include "desktop-widgets/divelistview.h" | ||||||
| #include "desktop-widgets/downloadfromdivecomputer.h" | #include "desktop-widgets/downloadfromdivecomputer.h" | ||||||
| #include "desktop-widgets/subsurfacewebservices.h" | #include "desktop-widgets/subsurfacewebservices.h" | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| // SPDX-License-Identifier: GPL-2.0
 | // SPDX-License-Identifier: GPL-2.0
 | ||||||
| #include "desktop-widgets/modeldelegates.h" | #include "desktop-widgets/modeldelegates.h" | ||||||
| #include "core/dive.h" | #include "core/dive.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| #include "core/gettextfromc.h" | #include "core/gettextfromc.h" | ||||||
| #include "desktop-widgets/mainwindow.h" | #include "desktop-widgets/mainwindow.h" | ||||||
| #include "qt-models/cylindermodel.h" | #include "qt-models/cylindermodel.h" | ||||||
|  |  | ||||||
|  | @ -13,6 +13,7 @@ | ||||||
| #include <errno.h> | #include <errno.h> | ||||||
| #include "core/cloudstorage.h" | #include "core/cloudstorage.h" | ||||||
| #include "core/dive.h" | #include "core/dive.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| 
 | 
 | ||||||
| #include <QDir> | #include <QDir> | ||||||
| #include <QHttpMultiPart> | #include <QHttpMultiPart> | ||||||
|  |  | ||||||
|  | @ -23,6 +23,7 @@ | ||||||
| #include "qt-models/divelocationmodel.h" | #include "qt-models/divelocationmodel.h" | ||||||
| #include "qt-models/filtermodels.h" | #include "qt-models/filtermodels.h" | ||||||
| #include "core/divesite.h" | #include "core/divesite.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| #include "desktop-widgets/locationinformation.h" | #include "desktop-widgets/locationinformation.h" | ||||||
| 
 | 
 | ||||||
| #include "TabDiveExtraInfo.h" | #include "TabDiveExtraInfo.h" | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ | ||||||
| #include "desktop-widgets/undocommands.h" | #include "desktop-widgets/undocommands.h" | ||||||
| #include "desktop-widgets/mainwindow.h" | #include "desktop-widgets/mainwindow.h" | ||||||
| #include "core/divelist.h" | #include "core/divelist.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| 
 | 
 | ||||||
| UndoDeleteDive::UndoDeleteDive(QList<dive *> deletedDives) : diveList(deletedDives) | UndoDeleteDive::UndoDeleteDive(QList<dive *> deletedDives) : diveList(deletedDives) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ | ||||||
| #include "qmlmanager.h" | #include "qmlmanager.h" | ||||||
| #include "profile-widget/profilewidget2.h" | #include "profile-widget/profilewidget2.h" | ||||||
| #include "core/dive.h" | #include "core/dive.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| #include "core/metrics.h" | #include "core/metrics.h" | ||||||
| #include <QTransform> | #include <QTransform> | ||||||
| #include <QScreen> | #include <QScreen> | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ | ||||||
| #include "profile-widget/divecartesianaxis.h" | #include "profile-widget/divecartesianaxis.h" | ||||||
| #include "profile-widget/divetextitem.h" | #include "profile-widget/divetextitem.h" | ||||||
| #include "core/helpers.h" | #include "core/helpers.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| #include "core/subsurface-qt/SettingsObjectWrapper.h" | #include "core/subsurface-qt/SettingsObjectWrapper.h" | ||||||
| #ifndef SUBSURFACE_MOBILE | #ifndef SUBSURFACE_MOBILE | ||||||
| #include "desktop-widgets/preferences/preferencesdialog.h" | #include "desktop-widgets/preferences/preferencesdialog.h" | ||||||
|  |  | ||||||
|  | @ -8,6 +8,7 @@ | ||||||
| #include "core/gettextfromc.h" | #include "core/gettextfromc.h" | ||||||
| #include "core/metrics.h" | #include "core/metrics.h" | ||||||
| #include "core/membuffer.h" | #include "core/membuffer.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| 
 | 
 | ||||||
| extern struct ev_select *ev_namelist; | extern struct ev_select *ev_namelist; | ||||||
| extern int evn_used; | extern int evn_used; | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| // SPDX-License-Identifier: GPL-2.0
 | // SPDX-License-Identifier: GPL-2.0
 | ||||||
| #include "profile-widget/profilewidget2.h" | #include "profile-widget/profilewidget2.h" | ||||||
| #include "qt-models/diveplotdatamodel.h" | #include "qt-models/diveplotdatamodel.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| #include "core/helpers.h" | #include "core/helpers.h" | ||||||
| #include "core/profile.h" | #include "core/profile.h" | ||||||
| #include "profile-widget/diveeventitem.h" | #include "profile-widget/diveeventitem.h" | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| // SPDX-License-Identifier: GPL-2.0
 | // SPDX-License-Identifier: GPL-2.0
 | ||||||
| #include "diveplannermodel.h" | #include "diveplannermodel.h" | ||||||
| #include "core/dive.h" | #include "core/dive.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| #include "core/helpers.h" | #include "core/helpers.h" | ||||||
| #include "qt-models/cylindermodel.h" | #include "qt-models/cylindermodel.h" | ||||||
| #include "core/planner.h" | #include "core/planner.h" | ||||||
|  |  | ||||||
|  | @ -5,6 +5,7 @@ | ||||||
| #include "core/divelist.h" | #include "core/divelist.h" | ||||||
| #include "core/helpers.h" | #include "core/helpers.h" | ||||||
| #include "core/dive.h" | #include "core/dive.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| #include <QIcon> | #include <QIcon> | ||||||
| #include <QDebug> | #include <QDebug> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ | ||||||
| #include "qt-models/filtermodels.h" | #include "qt-models/filtermodels.h" | ||||||
| #include "qt-models/models.h" | #include "qt-models/models.h" | ||||||
| #include "core/display.h" | #include "core/display.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| #include "qt-models/divetripmodel.h" | #include "qt-models/divetripmodel.h" | ||||||
| 
 | 
 | ||||||
| #if !defined(SUBSURFACE_MOBILE) | #if !defined(SUBSURFACE_MOBILE) | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| // SPDX-License-Identifier: GPL-2.0
 | // SPDX-License-Identifier: GPL-2.0
 | ||||||
| #include "qt-models/weightmodel.h" | #include "qt-models/weightmodel.h" | ||||||
| #include "core/dive.h" | #include "core/dive.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| #include "core/gettextfromc.h" | #include "core/gettextfromc.h" | ||||||
| #include "core/metrics.h" | #include "core/metrics.h" | ||||||
| #include "core/helpers.h" | #include "core/helpers.h" | ||||||
|  |  | ||||||
|  | @ -27,6 +27,7 @@ | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #include "core/dive.h" | #include "core/dive.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| #include "core/gettext.h" | #include "core/gettext.h" | ||||||
| #include "core/divelist.h" | #include "core/divelist.h" | ||||||
| #include "core/libdivecomputer.h" | #include "core/libdivecomputer.h" | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| // SPDX-License-Identifier: GPL-2.0
 | // SPDX-License-Identifier: GPL-2.0
 | ||||||
| #include "testparse.h" | #include "testparse.h" | ||||||
| #include "core/dive.h" | #include "core/dive.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| #include "core/parse.h" | #include "core/parse.h" | ||||||
| #include "core/file.h" | #include "core/file.h" | ||||||
| #include "core/divelist.h" | #include "core/divelist.h" | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| // SPDX-License-Identifier: GPL-2.0
 | // SPDX-License-Identifier: GPL-2.0
 | ||||||
| #include "testunitconversion.h" | #include "testunitconversion.h" | ||||||
| #include "core/dive.h" | #include "core/dive.h" | ||||||
|  | #include "core/subsurface-string.h" | ||||||
| 
 | 
 | ||||||
| void TestUnitConversion::testUnitConversions() | void TestUnitConversion::testUnitConversions() | ||||||
| { | { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue