Esempio n. 1
0
static int randomize_shebang(int fd) {

	int num_args,i,rand_length;

	write(fd,"#",1);

	if (rand()%2) insert_whitespace(fd);

	write(fd,"!",1);

	if (rand()%2) insert_whitespace(fd);

	switch(rand()%4) {
		case 0:	get_random_shell(filename, FILENAME_SIZE);
			break;
		case 1:	get_random_file(filename, FILENAME_SIZE, RANDOM_FILE_RANDOM);
			break;
		case 2:	get_random_file(filename, FILENAME_SIZE, RANDOM_FILE_SYSTEM);
			break;
		case 3:	get_random_file(filename, FILENAME_SIZE, RANDOM_FILE_EXECUTABLE);
			break;
	}

	/* Possibly corrupt filename */
	if (rand()%10==1) string_corrupt(filename);

	/* Write out filename */
	write(fd,filename,strlen(filename));

	if (rand()%2) insert_whitespace(fd);

	/* random number of command line args */
	switch(rand()%3) {
		case 0:	num_args=0; break;
		case 1:	num_args=rand()%4; break;
		case 2: num_args=rand()%20000; break;
		default:	num_args=0; break;
	}

	for(i=0;i<num_args;i++) {
		get_random_file(filename, FILENAME_SIZE, RANDOM_FILE_RANDOM);
		write(fd,filename,strlen(filename));

		insert_whitespace(fd);
	}

	/* write random data */
	if (rand()%2) {
		rand_length=rand()%FILENAME_SIZE;
		for(i=0;i<rand_length;i++) {
			filename[i]=rand();
		}
		write(fd,filename,rand_length);
	}

	return 0;
}
Esempio n. 2
0
File: cmds.c Progetto: hankem/jed
/* move cursor to column c adding spaces if necessary */
void goto_column(int *c)
{
   int c1 = *c;
   if (c1 <= 0) c1 = 1;
   c1 = c1 - goto_column1(&c1);
   insert_whitespace(&c1);
}
Esempio n. 3
0
File: cmds.c Progetto: hankem/jed
/* indent line to column n */
void indent_to(int n)
{
   int m;

   get_current_indent(&m);

   if (n != m)
     {
	bol ();
	if (-1 == jed_trim_whitespace())
	  return;
	if (n >= 0) insert_whitespace(&n);
     }
}