Fix formatting.
This commit is contained in:
		
							parent
							
								
									b666de95af
								
							
						
					
					
						commit
						f4791c5177
					
				
							
								
								
									
										14
									
								
								src/stack.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/stack.c
									
									
									
									
									
								
							@ -12,8 +12,8 @@
 | 
			
		||||
 | 
			
		||||
Stack *program_init(uint16_t stacksize)
 | 
			
		||||
{
 | 
			
		||||
    Stack *stack = calloc(1,sizeof(&stack) + sizeof(Instruction) * PROGRAM_MAXSIZE + sizeof(int16_t) * MAX_LABELS +
 | 
			
		||||
                          sizeof(uint16_t) * stacksize);
 | 
			
		||||
    Stack *stack = calloc(1, sizeof(&stack) + sizeof(Instruction) * PROGRAM_MAXSIZE + sizeof(int16_t) * MAX_LABELS +
 | 
			
		||||
                                 sizeof(uint16_t) * stacksize);
 | 
			
		||||
 | 
			
		||||
    stack->stacksize = stacksize;
 | 
			
		||||
 | 
			
		||||
@ -107,20 +107,20 @@ Stack *stack_callback_pointer;
 | 
			
		||||
 | 
			
		||||
void stack_init_callback(Stack *stack)
 | 
			
		||||
{
 | 
			
		||||
	stack_callback_pointer = stack;
 | 
			
		||||
    stack_callback_pointer = stack;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint16_t stack_pop_callback(void) 
 | 
			
		||||
uint16_t stack_pop_callback(void)
 | 
			
		||||
{
 | 
			
		||||
	return stack_pop(stack_callback_pointer);
 | 
			
		||||
    return stack_pop(stack_callback_pointer);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void stack_push_callback(uint16_t number)
 | 
			
		||||
{
 | 
			
		||||
	stack_push(stack_callback_pointer, number);
 | 
			
		||||
    stack_push(stack_callback_pointer, number);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_t stack_len_callback(void)
 | 
			
		||||
{
 | 
			
		||||
	return stack_callback_pointer->pointer;
 | 
			
		||||
    return stack_callback_pointer->pointer;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -3,46 +3,57 @@
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include "wincompat.h"
 | 
			
		||||
size_t getline(char **lineptr, size_t *n, FILE *stream) {
 | 
			
		||||
size_t getline(char **lineptr, size_t *n, FILE *stream)
 | 
			
		||||
{
 | 
			
		||||
    char *bufptr = NULL;
 | 
			
		||||
    char *p = bufptr;
 | 
			
		||||
    size_t size;
 | 
			
		||||
    int c;
 | 
			
		||||
 | 
			
		||||
    if (lineptr == NULL) {
 | 
			
		||||
    if (lineptr == NULL)
 | 
			
		||||
    {
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
    if (stream == NULL) {
 | 
			
		||||
    if (stream == NULL)
 | 
			
		||||
    {
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
    if (n == NULL) {
 | 
			
		||||
    if (n == NULL)
 | 
			
		||||
    {
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
    bufptr = *lineptr;
 | 
			
		||||
    size = *n;
 | 
			
		||||
 | 
			
		||||
    c = fgetc(stream);
 | 
			
		||||
    if (c == EOF) {
 | 
			
		||||
    if (c == EOF)
 | 
			
		||||
    {
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
    if (bufptr == NULL) {
 | 
			
		||||
    if (bufptr == NULL)
 | 
			
		||||
    {
 | 
			
		||||
        bufptr = malloc(128);
 | 
			
		||||
        if (bufptr == NULL) {
 | 
			
		||||
        if (bufptr == NULL)
 | 
			
		||||
        {
 | 
			
		||||
            return -1;
 | 
			
		||||
        }
 | 
			
		||||
        size = 128;
 | 
			
		||||
    }
 | 
			
		||||
    p = bufptr;
 | 
			
		||||
    while(c != EOF) {
 | 
			
		||||
        if ((p - bufptr) > (size - 1)) {
 | 
			
		||||
    while (c != EOF)
 | 
			
		||||
    {
 | 
			
		||||
        if ((p - bufptr) > (size - 1))
 | 
			
		||||
        {
 | 
			
		||||
            size = size + 128;
 | 
			
		||||
            bufptr = realloc(bufptr, size);
 | 
			
		||||
            if (bufptr == NULL) {
 | 
			
		||||
            if (bufptr == NULL)
 | 
			
		||||
            {
 | 
			
		||||
                return -1;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        *p++ = c;
 | 
			
		||||
        if (c == '\n') {
 | 
			
		||||
        if (c == '\n')
 | 
			
		||||
        {
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        c = fgetc(stream);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user