mirror of
				https://github.com/troglobit/editline.git
				synced 2025-10-31 16:28:15 +08:00 
			
		
		
		
	Revert "Coding style and const fixes to last PR"
This reverts commit fbb1f8800a.
			
			
This commit is contained in:
		| @@ -117,27 +117,37 @@ el_status_t do_suspend(void) | |||||||
|     return CSstay; |     return CSstay; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int my_rl_check_secret(const char *line) | static int my_rl_check_secret(const char* source) | ||||||
| { | { | ||||||
|     const char *pattern = (char *)"^unlock\\s"; |     const char* pattern = (char *)"^unlock\\s"; | ||||||
|     regex_t regex; |     regex_t regex; | ||||||
|     int rc = 0; |  | ||||||
|  |  | ||||||
|     if (!line || regcomp(®ex, pattern, 0)) |     int reti; | ||||||
|         return 0; |     int rez = 0; | ||||||
|  |  | ||||||
|     if (!regexec(®ex, line, 0, NULL, 0)) |     if (!pattern || !source) | ||||||
|         rc = 1; |         return rez; | ||||||
|  |  | ||||||
|  |     /* Compile regular expression */ | ||||||
|  |     reti = regcomp(®ex, pattern, 0); | ||||||
|  |     if (reti) // If couldn't compile regex | ||||||
|  |         return rez; | ||||||
|  |  | ||||||
|  |     /* Execute regular expression */ | ||||||
|  |     reti = regexec(®ex, source, 0, NULL, 0); | ||||||
|  |     if (!reti) // If regex match | ||||||
|  |         rez = 1; | ||||||
|  |  | ||||||
|  |     /* Free memory allocated to the pattern buffer by regcomp() */ | ||||||
|     regfree(®ex); |     regfree(®ex); | ||||||
|  |  | ||||||
|     return rc; |     return rez; | ||||||
| } | } | ||||||
|  |  | ||||||
| int main(void) | int main(void) | ||||||
| { | { | ||||||
|     char *line; |     char *line; | ||||||
|     char *prompt = "cli> "; |     char	*prompt = "cli> "; | ||||||
|  |  | ||||||
|     /* Setup callbacks */ |     /* Setup callbacks */ | ||||||
|     rl_set_complete_func(&my_rl_complete); |     rl_set_complete_func(&my_rl_complete); | ||||||
|   | |||||||
| @@ -77,7 +77,7 @@ extern char       *rl_complete(char *token, int *match); | |||||||
| extern int         rl_list_possib(char *token, char ***av); | extern int         rl_list_possib(char *token, char ***av); | ||||||
| extern char      **rl_completion_matches(const char *token, rl_compentry_func_t *generator); | extern char      **rl_completion_matches(const char *token, rl_compentry_func_t *generator); | ||||||
| extern char       *rl_filename_completion_function(const char *text, int state); | extern char       *rl_filename_completion_function(const char *text, int state); | ||||||
| extern int         rl_check_secret(const char *source); | extern int         rl_check_secret(char *source); | ||||||
|  |  | ||||||
| /* For compatibility with FSF readline. */ | /* For compatibility with FSF readline. */ | ||||||
| extern int         rl_point; | extern int         rl_point; | ||||||
|   | |||||||
| @@ -398,22 +398,17 @@ char *rl_complete(char *token, int *match) | |||||||
| } | } | ||||||
|  |  | ||||||
| static rl_check_secret_func_t *el_check_secret_func = NULL; | static rl_check_secret_func_t *el_check_secret_func = NULL; | ||||||
|  | /* For compatibility with the Heimdal project. */ | ||||||
| /* Added for the BitShares Core project. */ |  | ||||||
| rl_check_secret_func_t *rl_set_check_secret_func(rl_check_secret_func_t *func) | rl_check_secret_func_t *rl_set_check_secret_func(rl_check_secret_func_t *func) | ||||||
| { | { | ||||||
|     rl_check_secret_func_t *old = el_check_secret_func; |     rl_check_secret_func_t *old = el_check_secret_func; | ||||||
|  |  | ||||||
|     el_check_secret_func = func; |     el_check_secret_func = func; | ||||||
|  |  | ||||||
|     return old; |     return old; | ||||||
| } | } | ||||||
|  | int rl_check_secret(char *source) | ||||||
| int rl_check_secret(const char *line) |  | ||||||
| { | { | ||||||
|     if (el_check_secret_func) |     if (el_check_secret_func) | ||||||
| 	     return el_check_secret_func(line); | 	     return el_check_secret_func(source); | ||||||
|  |  | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1138,7 +1138,7 @@ static void hist_add(const char *p) | |||||||
|     if (s == NULL) |     if (s == NULL) | ||||||
|         return; |         return; | ||||||
|  |  | ||||||
|     /* Don't add secret information in history */ |     // Don't add secret information in history | ||||||
|     if (rl_check_secret(s)) |     if (rl_check_secret(s)) | ||||||
|         return; |         return; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Joachim Nilsson
					Joachim Nilsson