pwman

Check-in [378769ec43]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Extend the "don't overwrite fields if only carriage return is entered" to password field And also use malloc. What I'd done before wasn't doing what I thought. C newbie and all that. It must have picked up whatever `input` was initialised at, which must be one of STRING_SHORT, STRING_MEDIUM, etc. So it was just by luck it was working. It could have ended up truncating strings I guess? I'm in two minds about the benefit of dynamic allocation though. Since this is hardly a big memory hungry application I could probably just set `oldinput` to the largest possible string length and it'd be fine.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/tweaks | trunk
Files: files | file ages | folders
SHA3-256: 378769ec4367269d3ca376640adf89657d04b935313bcfbb3ad0dd88b69ff507
User & Date: atomicules@lavabit.com 2013-03-23 21:27:08
Context
2014-01-03
22:31
Merge branch 'modernise' into tweaks check-in: 229ff25e0f user: base@atomicules.co.uk tags: origin/tweaks, trunk
22:25
WIP on tweaks: 98593a8 Extend the "don't overwrite fields if only carriage return is entered" to password field Leaf check-in: 4a8cb3e9a0 user: base@atomicules.co.uk tags: trunk, refs/stash
22:25
index on tweaks: 98593a8 Extend the "don't overwrite fields if only carriage return is entered" to password field check-in: db8bd43770 user: base@atomicules.co.uk tags: trunk, refs/stash
2013-03-23
21:27
Extend the "don't overwrite fields if only carriage return is entered" to password field And also use malloc. What I'd done before wasn't doing what I thought. C newbie and all that. It must have picked up whatever `input` was initialised at, which must be one of STRING_SHORT, STRING_MEDIUM, etc. So it was just by luck it was working. It could have ended up truncating strings I guess? I'm in two minds about the benefit of dynamic allocation though. Since this is hardly a big memory hungry application I could probably just set `oldinput` to the largest possible string length and it'd be fine. check-in: 378769ec43 user: atomicules@lavabit.com tags: origin/tweaks, trunk
2013-03-22
17:02
Don't overwrite fields if only carriage return is entered In other words, prevent accidentally deleting fields. This has always bugged me about PWman. If I edit an entry and accidentally press a number to edit one of the fields there is no way to escape out of this. You have to re-type or paste in the old value. This small change means that if you just enter return then the old value is kept. This is good enough for me. There is one downside: if you really want to make a field blank the only way to do it is by entering a space and then return - but I can't think of anytime I've ever wanted to do that. check-in: 1559d3c956 user: atomicules@lavabit.com tags: origin/tweaks, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/ui.c.

458
459
460
461
462
463
464
465
466
467

468
469
470
471
472
473
474
...
521
522
523
524
525
526
527

528
529
530
531
532
533
534
535
536

537




538
539
540
541
542
543
544
...
577
578
579
580
581
582
583





584
585
586

587
588
589
590
591
592
593

char *
ui_statusline_ask_str(char *msg, char *input, int len)
{
	char *tmp;
	char *tmp2;
	char *tmp3;
	char oldinput[strlen(input)];
	int x = strlen(msg) + 5;


	//Back-up the old value	
	strcpy(oldinput, input);

	if(input == NULL){
		input = malloc(len);
	}
	ui_statusline_clear();
................................................................................
         *tmp2 = 0;
      } else {
   		tmp++;
      }
	}
	
	// All done

	return input;
}

char *
ui_statusline_ask_str_with_autogen(char *msg, char *input, int len, char *(*autogen)(char *), int ch)
{
	int i = 0;
	int c;
	char *text[2], *s;

	int x;





	if(input == NULL){
		input = malloc(len);
	}
	text[0] = malloc(STRING_MEDIUM);
	text[1] = malloc(STRING_SHORT);
	
................................................................................
			i++;
		}
	}
	
	hide_cursor();
	
	ui_statusline_clear();






	free(text[0]);
	free(text[1]);


	return input;
}

char *
ui_statusline_ask_passwd(char *msg, char *input, int len, int cancel)
{







|


>







 







>









>

>
>
>
>







 







>
>
>
>
>



>







458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
...
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
...
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606

char *
ui_statusline_ask_str(char *msg, char *input, int len)
{
	char *tmp;
	char *tmp2;
	char *tmp3;
	char *oldinput;
	int x = strlen(msg) + 5;

	oldinput = malloc(strlen(input)+1);
	//Back-up the old value	
	strcpy(oldinput, input);

	if(input == NULL){
		input = malloc(len);
	}
	ui_statusline_clear();
................................................................................
         *tmp2 = 0;
      } else {
   		tmp++;
      }
	}
	
	// All done
	free(oldinput);
	return input;
}

char *
ui_statusline_ask_str_with_autogen(char *msg, char *input, int len, char *(*autogen)(char *), int ch)
{
	int i = 0;
	int c;
	char *text[2], *s;
	char *oldinput;
	int x;

	oldinput = malloc(strlen(input)+1);
	//Back-up the old value	
	strcpy(oldinput, input);

	if(input == NULL){
		input = malloc(len);
	}
	text[0] = malloc(STRING_MEDIUM);
	text[1] = malloc(STRING_SHORT);
	
................................................................................
			i++;
		}
	}
	
	hide_cursor();
	
	ui_statusline_clear();

	//If just return entered, don't overwrite old value
	if(strlen(input) == 0){
		strcpy(input, oldinput);
	}

	free(text[0]);
	free(text[1]);
	free(oldinput);

	return input;
}

char *
ui_statusline_ask_passwd(char *msg, char *input, int len, int cancel)
{