mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
Added std:: prefix to more C standard library uses (#106)
This commit is contained in:
committed by
Peter Johnson
parent
daa0260a4e
commit
cee9b2609d
@@ -116,7 +116,7 @@ void IterativeRobot::StartCompetition() {
|
||||
* ready, causing the robot to be bypassed in a match.
|
||||
*/
|
||||
void IterativeRobot::RobotInit() {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +127,7 @@ void IterativeRobot::RobotInit() {
|
||||
* the robot enters disabled mode.
|
||||
*/
|
||||
void IterativeRobot::DisabledInit() {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +137,7 @@ void IterativeRobot::DisabledInit() {
|
||||
* called each time the robot enters autonomous mode.
|
||||
*/
|
||||
void IterativeRobot::AutonomousInit() {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,7 +147,7 @@ void IterativeRobot::AutonomousInit() {
|
||||
* called each time the robot enters teleop mode.
|
||||
*/
|
||||
void IterativeRobot::TeleopInit() {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,7 +157,7 @@ void IterativeRobot::TeleopInit() {
|
||||
* called each time the robot enters test mode.
|
||||
*/
|
||||
void IterativeRobot::TestInit() {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,7 +169,7 @@ void IterativeRobot::TestInit() {
|
||||
void IterativeRobot::DisabledPeriodic() {
|
||||
static bool firstRun = true;
|
||||
if (firstRun) {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
firstRun = false;
|
||||
}
|
||||
}
|
||||
@@ -183,7 +183,7 @@ void IterativeRobot::DisabledPeriodic() {
|
||||
void IterativeRobot::AutonomousPeriodic() {
|
||||
static bool firstRun = true;
|
||||
if (firstRun) {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
firstRun = false;
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,7 @@ void IterativeRobot::AutonomousPeriodic() {
|
||||
void IterativeRobot::TeleopPeriodic() {
|
||||
static bool firstRun = true;
|
||||
if (firstRun) {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
firstRun = false;
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ void IterativeRobot::TeleopPeriodic() {
|
||||
void IterativeRobot::TestPeriodic() {
|
||||
static bool firstRun = true;
|
||||
if (firstRun) {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
firstRun = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ RobotBase::RobotBase() : m_ds(DriverStation::GetInstance()) {
|
||||
NetworkTable::SetPersistentFilename("/home/lvuser/networktables.ini");
|
||||
|
||||
FILE* file = nullptr;
|
||||
file = fopen("/tmp/frc_versions/FRC_Lib_Version.ini", "w");
|
||||
file = std::fopen("/tmp/frc_versions/FRC_Lib_Version.ini", "w");
|
||||
|
||||
if (file != nullptr) {
|
||||
fputs("2016 C++ Release 5", file);
|
||||
fclose(file);
|
||||
std::fputs("2016 C++ Release 5", file);
|
||||
std::fclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ SampleRobot::SampleRobot() : m_robotMainOverridden(true) {}
|
||||
* ready, causing the robot to be bypassed in a match.
|
||||
*/
|
||||
void SampleRobot::RobotInit() {
|
||||
printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ void SampleRobot::RobotInit() {
|
||||
* field is disabled.
|
||||
*/
|
||||
void SampleRobot::Disabled() {
|
||||
printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,7 +49,7 @@ void SampleRobot::Disabled() {
|
||||
* robot enters the autonomous state.
|
||||
*/
|
||||
void SampleRobot::Autonomous() {
|
||||
printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ void SampleRobot::Autonomous() {
|
||||
* each time the robot enters the teleop state.
|
||||
*/
|
||||
void SampleRobot::OperatorControl() {
|
||||
printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ void SampleRobot::OperatorControl() {
|
||||
* test mode
|
||||
*/
|
||||
void SampleRobot::Test() {
|
||||
printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,7 @@ Servo::Servo(uint32_t channel) : SafePWM(channel) {
|
||||
// Assign defaults for period multiplier for the servo PWM control signal
|
||||
SetPeriodMultiplier(kPeriodMultiplier_4X);
|
||||
|
||||
// printf("Done initializing servo %d\n", channel);
|
||||
// std::printf("Done initializing servo %d\n", channel);
|
||||
}
|
||||
|
||||
Servo::~Servo() {
|
||||
|
||||
@@ -71,7 +71,8 @@ void dprintf(const char* tempString, ...) /* Variable argument list */
|
||||
filename = tempString;
|
||||
for (index = 0; index < tempStringLen; index++) {
|
||||
if (tempString[index] == ' ') {
|
||||
printf("ERROR in dprintf: malformed calling sequence (%s)\n", tempString);
|
||||
std::printf("ERROR in dprintf: malformed calling sequence (%s)\n",
|
||||
tempString);
|
||||
va_end(args);
|
||||
return;
|
||||
}
|
||||
@@ -91,40 +92,40 @@ void dprintf(const char* tempString, ...) /* Variable argument list */
|
||||
/* Extract format from argument list */
|
||||
fmt = va_arg(args, const char*);
|
||||
|
||||
vsprintf(text, fmt, args);
|
||||
std::vsprintf(text, fmt, args);
|
||||
|
||||
va_end(args);
|
||||
|
||||
/* Format output statement */
|
||||
switch (type) {
|
||||
case DEBUG_TYPE:
|
||||
sprintf(outtext, "[%s:%s@%04d] DEBUG %s\n", filename, functionName,
|
||||
line_number, text);
|
||||
std::sprintf(outtext, "[%s:%s@%04d] DEBUG %s\n", filename, functionName,
|
||||
line_number, text);
|
||||
break;
|
||||
case INFO_TYPE:
|
||||
sprintf(outtext, "[%s:%s@%04d] INFO %s\n", filename, functionName,
|
||||
line_number, text);
|
||||
std::sprintf(outtext, "[%s:%s@%04d] INFO %s\n", filename, functionName,
|
||||
line_number, text);
|
||||
break;
|
||||
case ERROR_TYPE:
|
||||
sprintf(outtext, "[%s:%s@%04d] ERROR %s\n", filename, functionName,
|
||||
line_number, text);
|
||||
std::sprintf(outtext, "[%s:%s@%04d] ERROR %s\n", filename, functionName,
|
||||
line_number, text);
|
||||
break;
|
||||
case CRITICAL_TYPE:
|
||||
sprintf(outtext, "[%s:%s@%04d] CRITICAL %s\n", filename, functionName,
|
||||
line_number, text);
|
||||
std::sprintf(outtext, "[%s:%s@%04d] CRITICAL %s\n", filename,
|
||||
functionName, line_number, text);
|
||||
break;
|
||||
case FATAL_TYPE:
|
||||
fatalFlag = 1;
|
||||
sprintf(outtext, "[%s:%s@%04d] FATAL %s\n", filename, functionName,
|
||||
line_number, text);
|
||||
std::sprintf(outtext, "[%s:%s@%04d] FATAL %s\n", filename, functionName,
|
||||
line_number, text);
|
||||
break;
|
||||
default:
|
||||
printf("ERROR in dprintf: malformed calling sequence\n");
|
||||
std::printf("ERROR in dprintf: malformed calling sequence\n");
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
sprintf(filepath, "%s.debug", filename);
|
||||
std::sprintf(filepath, "%s.debug", filename);
|
||||
|
||||
/* Write output statement */
|
||||
switch (dprintfFlag) {
|
||||
@@ -133,26 +134,26 @@ void dprintf(const char* tempString, ...) /* Variable argument list */
|
||||
break;
|
||||
case DEBUG_MOSTLY_OFF:
|
||||
if (fatalFlag) {
|
||||
if ((outfile_fd = fopen(filepath, "a+")) != nullptr) {
|
||||
fwrite(outtext, sizeof(char), strlen(outtext), outfile_fd);
|
||||
fclose(outfile_fd);
|
||||
if ((outfile_fd = std::fopen(filepath, "a+")) != nullptr) {
|
||||
std::fwrite(outtext, sizeof(char), std::strlen(outtext), outfile_fd);
|
||||
std::fclose(outfile_fd);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DEBUG_SCREEN_ONLY:
|
||||
printf("%s", outtext);
|
||||
std::printf("%s", outtext);
|
||||
break;
|
||||
case DEBUG_FILE_ONLY:
|
||||
if ((outfile_fd = fopen(filepath, "a+")) != nullptr) {
|
||||
if ((outfile_fd = std::fopen(filepath, "a+")) != nullptr) {
|
||||
fwrite(outtext, sizeof(char), strlen(outtext), outfile_fd);
|
||||
fclose(outfile_fd);
|
||||
std::fclose(outfile_fd);
|
||||
}
|
||||
break;
|
||||
case DEBUG_SCREEN_AND_FILE: // BOTH
|
||||
printf("%s", outtext);
|
||||
if ((outfile_fd = fopen(filepath, "a+")) != nullptr) {
|
||||
std::printf("%s", outtext);
|
||||
if ((outfile_fd = std::fopen(filepath, "a+")) != nullptr) {
|
||||
fwrite(outtext, sizeof(char), strlen(outtext), outfile_fd);
|
||||
fclose(outfile_fd);
|
||||
std::fclose(outfile_fd);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -187,7 +188,7 @@ float NormalizeToRange(float normalizedValue) {
|
||||
|
||||
/**
|
||||
* @brief Displays an activity indicator to console.
|
||||
* Call this function like you would call printf.
|
||||
* Call this function like you would call std::printf.
|
||||
* @param fmt The format string
|
||||
*/
|
||||
void ShowActivity(char* fmt, ...) {
|
||||
@@ -301,13 +302,13 @@ int processFile(char* inputFile, char* outputString, int lineNumber) {
|
||||
|
||||
if (lineNumber < 0) return (-1);
|
||||
|
||||
if ((infile = fopen(inputFile, "r")) == nullptr) {
|
||||
printf("Fatal error opening file %s\n", inputFile);
|
||||
if ((infile = std::fopen(inputFile, "r")) == nullptr) {
|
||||
std::printf("Fatal error opening file %s\n", inputFile);
|
||||
return (0);
|
||||
}
|
||||
|
||||
while (!feof(infile)) {
|
||||
if (fgets(inputStr, stringSize, infile) != nullptr) {
|
||||
while (!std::feof(infile)) {
|
||||
if (std::fgets(inputStr, stringSize, infile) != nullptr) {
|
||||
// Skip empty lines
|
||||
if (emptyString(inputStr)) continue;
|
||||
// Skip comment lines
|
||||
@@ -323,14 +324,14 @@ int processFile(char* inputFile, char* outputString, int lineNumber) {
|
||||
}
|
||||
|
||||
// close file
|
||||
fclose(infile);
|
||||
std::fclose(infile);
|
||||
// if number lines requested return the count
|
||||
if (lineNumber == 0) return (lineCount);
|
||||
// check for input out of range
|
||||
if (lineNumber > lineCount) return (-1);
|
||||
// return the line selected; lineCount guaranteed to be greater than zero
|
||||
stripString(inputStr);
|
||||
strcpy(outputString, inputStr);
|
||||
std::strcpy(outputString, inputStr);
|
||||
return (lineCount);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user