File: bump.c

package info (click to toggle)
netdiag 0.7-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,464 kB
  • ctags: 1,261
  • sloc: ansic: 12,948; makefile: 288; awk: 130; sh: 71
file content (64 lines) | stat: -rw-r--r-- 1,082 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <stdio.h>
/*
	bump version as

	bump version 
		whatever your version... do letter increment
	bump version n
		whatever your version... upgrade sub num.... 0.6d -> 0.7
	bump version r
		whatever your version... upgrade prime num.... 0.6d -> 1.0a
	

*/
int main( int argc, char *argv[])
{
	char lastkey;
	char subnum;
	char primnum;
	static char version[180];
	int lastspot;
	int bumpprim = 0;
	int bumpsub = 0;

	if (argc<2)
	{
		printf("0.0a");
		exit(1);
	}
	
	if (argc>2 && argv[2][0]=='n')
		bumpsub = 1;
	if (argc>2 && argv[2][0]=='r')
		bumpprim = 1;

	strcpy(version,argv[1]);
	if (strlen(version)<4)
	{
		printf("0.0a");
		exit(2);
	}
	lastspot = strlen(version) -1;
	lastkey = version[lastspot];
	subnum = version[lastspot-1];
	primnum = version[lastspot-3];

	if (!bumpsub && !bumpprim && lastkey<'z')
		version[lastspot]++;
	else	
	{
		if (!bumpprim && subnum<'9')
		{
			version[lastspot]='a';
			version[lastspot-1]++;
		}
		else
		{
			version[lastspot]='a';
			version[lastspot-1]='0';
			version[lastspot-3]++;
		}
	}
	printf("%s\n",version);
	return(0);
}