Skip to content

Commit

Permalink
Merge pull request #1 from opennars/master
Browse files Browse the repository at this point in the history
pull latest
  • Loading branch information
yuhongsun96 authored Feb 25, 2020
2 parents c8c2b45 + 9505371 commit ba8f02e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
12 changes: 12 additions & 0 deletions src/Globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,15 @@ void assert(bool b, char* message)
exit(1);
}
}

void strtrim(char *line)
{
for(int i=strlen(line)-1; i>=0; i--)
{
if(!isspace(line[i]))
{
break;
}
line[i] = 0;
}
}
5 changes: 5 additions & 0 deletions src/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#define GLOBALS_H

#include <stdbool.h>
#include <string.h>
#include <ctype.h>

/*-------*/
/* Flags */
Expand All @@ -49,7 +51,10 @@
#define PRINTD(format, args...) ((void)0)
#endif
#define IN_DEBUG(x) {if(DEBUG){ x } }
//assert, printing message and exiting if b=false
void assert(bool b, char* message);
//trim a string, standard library "extension"
void strtrim(char *line);
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))

Expand Down
1 change: 1 addition & 0 deletions src/NetworkNAR/UDPNAR.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ void* Receive_Thread_Run(void *sockfd_address)
{
break;
}
strtrim(buffer);
pthread_mutex_lock(&nar_mutex);
NAR_AddInputNarsese(buffer);
pthread_mutex_unlock(&nar_mutex);
Expand Down
9 changes: 1 addition & 8 deletions src/Shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,7 @@ void Shell_Start()
exit(0);
}
//trim string, for IRC etc. convenience
for(int i=strlen(line)-1; i>=0; i--)
{
if(!isspace(line[i]))
{
break;
}
line[i] = 0;
}
strtrim(line);
int size = strlen(line);
if(size==0)
{
Expand Down
1 change: 0 additions & 1 deletion src/Shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
//References//
//----------//
#include "NAR.h"
#include <ctype.h>
#include "Stats.h"

//Methods//
Expand Down

0 comments on commit ba8f02e

Please sign in to comment.