strncpy fixed

replaced reference to strncpy with bcopy
master
WHPThomas 2013-04-19 03:36:22 +10:00
parent 12961a7eca
commit f99a6f5fde
2 changed files with 18 additions and 9 deletions

24
gpx.c
View File

@ -365,12 +365,10 @@ static int config_handler(void* user, const char* section, const char* name, con
// compute the filament scaling factor
void set_filament_scale(unsigned extruder_id) {
double actual_radious = override[extruder_id].actual_filament_diameter / 2;
double actual = actual_radious * actual_radious;
double nominal_radious = machine.nominal_filament_diameter / 2;
double nominal = nominal_radious * nominal_radious;
override[extruder_id].filament_scale = nominal / actual;
static void set_filament_scale(unsigned extruder_id) {
double actual_radius = override[extruder_id].actual_filament_diameter / 2;
double nominal_radius = machine.nominal_filament_diameter / 2;
override[extruder_id].filament_scale = (nominal_radius * nominal_radius) / (actual_radius * actual_radius);
}
// return the magnitude (length) of the 5D vector
@ -459,7 +457,7 @@ static double get_home_feedrate(int flag) {
// return the maximum safe feedrate
double get_safe_feedrate(int flag, Ptr5d delta) {
static double get_safe_feedrate(int flag, Ptr5d delta) {
double feedrate = currentFeedrate;
if(feedrate == 0.0) {
@ -889,7 +887,7 @@ static void set_beep(unsigned frequency, unsigned milliseconds)
// 149 - Display message to LCD
void display_message(char *message, unsigned timeout, int wait_for_button)
static void display_message(char *message, unsigned timeout, int wait_for_button)
{
long bytesSent = 0;
unsigned bitfield = 0;
@ -1170,6 +1168,8 @@ static void set_acceleration(int state)
// 157 - Stream Version
// PARSER INPUT PREPROCESSORS
// return the length of the given file in bytes
static long get_filesize(FILE *file)
@ -1181,6 +1181,8 @@ static long get_filesize(FILE *file)
return filesize;
}
// clean up the gcode command for processing
static char *normalize_word(char* p)
{
// we expect a letter followed by a digit
@ -1224,6 +1226,8 @@ static char *normalize_word(char* p)
return s;
}
// clean up the gcode comment for processing
static char *normalize_comment(char *p) {
// strip white space from the end of comment
char *e = p + strlen(p);
@ -1233,6 +1237,8 @@ static char *normalize_comment(char *p) {
return p;
}
// display usage and exit
static void usage()
{
fputs("GPX " GPX_VERSION " Copyright (c) 2013 WHPThomas, All rights reserved." EOL, stderr);
@ -1256,6 +1262,8 @@ static void usage()
exit(1);
}
// program entry point
int main(int argc, char * argv[])
{
long filesize = 0;

3
ini.c
View File

@ -53,7 +53,8 @@ static char* find_char_or_comment(const char* s, char c)
/* Version of strncpy that ensures dest (size bytes) is null-terminated. */
static char* strncpy0(char* dest, const char* src, size_t size)
{
strncpy(dest, src, size);
//strncpy(dest, src, size);
bcopy(src, dest, size);
dest[size - 1] = '\0';
return dest;
}