calculate the # of digits with log10 and free str
This commit is contained in:
		
							parent
							
								
									f0c3f1a0f6
								
							
						
					
					
						commit
						329e4ff9c6
					
				
							
								
								
									
										10
									
								
								termite.cc
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								termite.cc
									
									
									
									
									
								
							| @ -760,15 +760,13 @@ gboolean entry_key_press_cb(GtkEntry *entry, GdkEventKey *event, keybind_info *i | |||||||
|                 const char *const text = gtk_entry_get_text(entry); |                 const char *const text = gtk_entry_get_text(entry); | ||||||
|                 char *fulltext = g_strndup(text, strlen(text) + 1); |                 char *fulltext = g_strndup(text, strlen(text) + 1); | ||||||
|                 fulltext[strlen(text)] = (char)event->keyval; |                 fulltext[strlen(text)] = (char)event->keyval; | ||||||
|                 char *str_ptr = (char*)malloc(sizeof(text)); |                 size_t base10_digits = static_cast<size_t>( | ||||||
|                 sprintf(str_ptr, "%d", (int)info->panel.url_list.size()); |                     log10(static_cast<double>(info->panel.url_list.size())) + 1); | ||||||
|                 int url_num = (int)strlen(str_ptr); |                 if (strlen(fulltext) == base10_digits) { | ||||||
|                 free(str_ptr); |  | ||||||
|                 int inp_num = (int)strlen(fulltext); |  | ||||||
|                 if (url_num == inp_num) { |  | ||||||
|                     launch_url(info->config.browser, fulltext, &info->panel); |                     launch_url(info->config.browser, fulltext, &info->panel); | ||||||
|                     ret = TRUE; |                     ret = TRUE; | ||||||
|                 } |                 } | ||||||
|  |                 free(fulltext); | ||||||
|             } |             } | ||||||
|             break; |             break; | ||||||
|         case GDK_KEY_Tab: |         case GDK_KEY_Tab: | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Daniel Micay
						Daniel Micay