fix "inverse copy&pasto" in account labeling code
the code was copied and the original adjusted ... but not quite
completely.
this means that clashing server names never really worked since - not
that i would have expected this to be a particularly common
configuration to start with. :D
also added comments explaining why there are two implementations of the
same thing.
amends aea4be19e3 (anno 2006).
found by coverity.
			
			
This commit is contained in:
		
							parent
							
								
									9932352df0
								
							
						
					
					
						commit
						d7d5fd20bc
					
				
					 1 changed files with 5 additions and 1 deletions
				
			
		| 
						 | 
					@ -247,6 +247,8 @@ write_imap_server( FILE *fp, config_t *cfg )
 | 
				
			||||||
	char buf[128], ubuf[64];
 | 
						char buf[128], ubuf[64];
 | 
				
			||||||
	static int tunnels;
 | 
						static int tunnels;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* The old server names determine the derived store names. They are kinda stupid,
 | 
				
			||||||
 | 
						 * but can't be changed, because store names are encoded in state file names. */
 | 
				
			||||||
	if (cfg->tunnel)
 | 
						if (cfg->tunnel)
 | 
				
			||||||
		nfasprintf( (char **)&cfg->old_server_name, "tunnel%d", ++tunnels );
 | 
							nfasprintf( (char **)&cfg->old_server_name, "tunnel%d", ++tunnels );
 | 
				
			||||||
	else {
 | 
						else {
 | 
				
			||||||
| 
						 | 
					@ -266,7 +268,7 @@ write_imap_server( FILE *fp, config_t *cfg )
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (boxes) /* !o2o */
 | 
							if (boxes) /* !o2o */
 | 
				
			||||||
			for (pbox = boxes; pbox != cfg; pbox = pbox->next)
 | 
								for (pbox = boxes; pbox != cfg; pbox = pbox->next)
 | 
				
			||||||
				if (!memcmp( pbox->server_name, buf, hl + 1 )) {
 | 
									if (!memcmp( pbox->old_server_name, buf, hl + 1 )) {
 | 
				
			||||||
					nfasprintf( (char **)&cfg->old_server_name, "%s-%d", buf, ++pbox->old_servers );
 | 
										nfasprintf( (char **)&cfg->old_server_name, "%s-%d", buf, ++pbox->old_servers );
 | 
				
			||||||
					goto gotsrv;
 | 
										goto gotsrv;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
| 
						 | 
					@ -275,6 +277,8 @@ write_imap_server( FILE *fp, config_t *cfg )
 | 
				
			||||||
	  gotsrv: ;
 | 
						  gotsrv: ;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* The "new" server names determine the names of the accounts themselves.
 | 
				
			||||||
 | 
						 * They are optimized for descriptiveness, e.g. in password prompts. */
 | 
				
			||||||
	if (cfg->user)
 | 
						if (cfg->user)
 | 
				
			||||||
		nfsnprintf( ubuf, sizeof(ubuf), "%s@", cfg->user );
 | 
							nfsnprintf( ubuf, sizeof(ubuf), "%s@", cfg->user );
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue