Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.28 KB | None | 0 0
  1. #include "over.h"
  2.  
  3. char currentstate;
  4. unsigned char Wbuffer[100];
  5. int linecount = 0;
  6.  
  7. void operantFIND(int lines, int spacestatus);
  8. void removeSpace(unsigned char *org);
  9.  
  10. FILE_LOGS file_log;
  11.  
  12. int main(){
  13.     printf("*Welcome to the crep x86 assembler*\n\n\n\nenter name of file you would like to assemble: ");
  14.     scanf("%s", &res);
  15.     fp  = fopen(res, "r");
  16.     tmp = fopen("remove-blanks.tmp", "w");
  17.     while ((fgets(buffer, 1000, fp)) != NULL)
  18.     {
  19.         int check = 0;
  20.         const char *currentptr;
  21.         currentptr = buffer;
  22.         do
  23.         {
  24.             currentstate = *(currentptr++);
  25.             if(currentstate != '\n' && currentstate != '\0' && currentstate != ' ' && currentstate != '\t' && currentstate != '\r')
  26.                 break;
  27.             check++;
  28.         } while(currentstate != '\0');
  29.        
  30.         if(!check)
  31.             fputs(buffer, tmp);
  32.     }
  33.     fclose(fp);
  34.     fclose(tmp);
  35.  
  36.     remove(res);
  37.     rename("remove-blanks.tmp", res);
  38.  
  39.     fp = fopen(res, "r+");
  40.  
  41.     while((currentstate = fgetc(fp)) != EOF)
  42.     {
  43.         if(currentstate == '\n')
  44.             linecount++;
  45.     }
  46.     rewind(fp);
  47.     operantFIND(6, 1);
  48.    
  49.     for( int i = 0; i < 36; i++ )
  50.     {
  51.         if(!strcmp(Wbuffer, IDENT[i]))
  52.         {
  53.             strcpy(file_log.yestype, Wbuffer);
  54.             break;
  55.         }
  56.         if(strcmp(Wbuffer, IDENT[i]) >= 1)
  57.         {
  58.             strcpy(file_log.nontype, Wbuffer);
  59.             break;
  60.         }
  61.     }
  62.     printf("yestype: %s\n", file_log.yestype);
  63.     printf("nontype: %s\n", file_log.nontype);
  64.     printf("crep: %s\n", Wbuffer);
  65. }
  66. void operantFIND(int lines, int spacestatus)
  67. {
  68.     int j, i = 0;
  69.     do
  70.     {
  71.         fgets(buffer, sizeof(buffer) - strlen(buffer), fp);
  72.         i++;
  73.     } while( i != lines );
  74.  
  75.     char check;
  76.     switch(spacestatus)
  77.     {
  78.         case 0: check = ',';
  79.         case 1: check = ' ';
  80.         default: ',';
  81.     }
  82.     for( j = 0; j < strlen(buffer); j++ )
  83.         if( buffer[j] == check ) break;
  84.     strncpy( Wbuffer, buffer + j + 1, strlen(buffer) - j );
  85.     printf("%s", Wbuffer);
  86.     removeSpace(Wbuffer);
  87. }
  88. void removeSpace(unsigned char* org) {
  89.     const unsigned char* ref = org;
  90.     do {  while (*ref == ' ') ++ref; } while (*org++ = *ref++);
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement