mirror of
				https://github.com/raysan5/raylib.git
				synced 2025-10-26 12:27:01 +00:00 
			
		
		
		
	TextToInteger() always exposed
This commit is contained in:
		
							
								
								
									
										36
									
								
								src/text.c
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								src/text.c
									
									
									
									
									
								
							| @@ -1132,6 +1132,24 @@ const char *TextFormat(const char *text, ...) | |||||||
|     return currentBuffer; |     return currentBuffer; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Get integer value from text | ||||||
|  | // NOTE: This function replaces atoi() [stdlib.h] | ||||||
|  | int TextToInteger(const char *text) | ||||||
|  | { | ||||||
|  |     int value = 0; | ||||||
|  |     int sign = 1; | ||||||
|  |  | ||||||
|  |     if ((text[0] == '+') || (text[0] == '-')) | ||||||
|  |     { | ||||||
|  |         if (text[0] == '-') sign = -1; | ||||||
|  |         text++; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     for (int i = 0; ((text[i] >= '0') && (text[i] <= '9')); ++i) value = value*10 + (int)(text[i] - '0'); | ||||||
|  |  | ||||||
|  |     return value*sign; | ||||||
|  | } | ||||||
|  |  | ||||||
| #if defined(SUPPORT_TEXT_MANIPULATION) | #if defined(SUPPORT_TEXT_MANIPULATION) | ||||||
| // Copy one string to another, returns bytes copied | // Copy one string to another, returns bytes copied | ||||||
| int TextCopy(char *dst, const char *src) | int TextCopy(char *dst, const char *src) | ||||||
| @@ -1415,24 +1433,6 @@ const char *TextToPascal(const char *text) | |||||||
|     return buffer; |     return buffer; | ||||||
| } | } | ||||||
|  |  | ||||||
| // Get integer value from text |  | ||||||
| // NOTE: This function replaces atoi() [stdlib.h] |  | ||||||
| int TextToInteger(const char *text) |  | ||||||
| { |  | ||||||
|     int value = 0; |  | ||||||
|     int sign = 1; |  | ||||||
|  |  | ||||||
|     if ((text[0] == '+') || (text[0] == '-')) |  | ||||||
|     { |  | ||||||
|         if (text[0] == '-') sign = -1; |  | ||||||
|         text++; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     for (int i = 0; ((text[i] >= '0') && (text[i] <= '9')); ++i) value = value*10 + (int)(text[i] - '0'); |  | ||||||
|  |  | ||||||
|     return value*sign; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Encode text codepoint into utf8 text (memory must be freed!) | // Encode text codepoint into utf8 text (memory must be freed!) | ||||||
| char *TextToUtf8(int *codepoints, int length) | char *TextToUtf8(int *codepoints, int length) | ||||||
| { | { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 raysan5
					raysan5