rewrite uses of strcpy w/ S
This commit is contained in:
parent
9f92eb4766
commit
53f5b05210
14
src/parser.c
14
src/parser.c
@ -21,9 +21,8 @@
|
||||
//takes inputted char array and returns the integer of the operand, skipping the first character
|
||||
//e.g. for a passed "R32", it skips the 'R' and returns 32
|
||||
int getOperandNumber(char *operand){
|
||||
char *operandCpy = NULL;
|
||||
strcpy(operandCpy, operand);
|
||||
operandCpy++;
|
||||
char operandCpy[strlen(operand)];
|
||||
strcpy(operandCpy, operand+1);
|
||||
char **endptr = NULL;
|
||||
int number = strtol(operandCpy, endptr, 10);
|
||||
return number;
|
||||
@ -97,9 +96,8 @@ void generateBranchOperands(a64inst_instruction *instr, char* opcode, char *oper
|
||||
break;
|
||||
case a64inst_CONDITIONAL:
|
||||
{
|
||||
char *condition = NULL;
|
||||
condition = strcpy(condition, opcode);
|
||||
condition += 2;
|
||||
char condition[strlen(opcode)+1];
|
||||
strcpy(condition, opcode+2);
|
||||
if(strcmp(condition, "eq")==0){
|
||||
instr->data.BranchData.processOpData.conditionalData.cond = EQ;
|
||||
} else if (strcmp(condition, "ne")==0){
|
||||
@ -223,8 +221,8 @@ void parser_instruction(char asmLine[], a64inst_instruction *instr) {
|
||||
//type is label
|
||||
//add to symbol table
|
||||
instr->type = a64inst_LABEL;
|
||||
char *opcodeCpy = NULL;
|
||||
opcodeCpy = strcpy(opcodeCpy, opcode);
|
||||
char opcodeCpy[strlen(opcode)+1];
|
||||
strcpy(opcodeCpy, opcode);
|
||||
char *labelData = strtok(opcodeCpy, ":");
|
||||
instr->data.LabelData.label = labelData;
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user