Skip to content

Commit ae726f3

Browse files
committed
Use the std namespace
1 parent 5128db3 commit ae726f3

File tree

7 files changed

+93
-94
lines changed

7 files changed

+93
-94
lines changed

3rdparty/basic/basic_interpreter.cpp

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -47,45 +47,45 @@ BasicInterpreter::BasicInterpreter()
4747

4848
/* 20 Commands must be entered lowercase in this table*/
4949
int x = 0;
50-
strcpy(table[x].command, "print");
50+
std::strcpy(table[x].command, "print");
5151
table[x++].tok = PRINT;
5252

53-
strcpy(table[x].command, "sin");
53+
std::strcpy(table[x].command, "sin");
5454
table[x++].tok = SIN;
55-
strcpy(table[x].command, "cos");
55+
std::strcpy(table[x].command, "cos");
5656
table[x++].tok = COS;
57-
strcpy(table[x].command, "tan");
57+
std::strcpy(table[x].command, "tan");
5858
table[x++].tok = TAN;
59-
strcpy(table[x].command, "sqrt");
59+
std::strcpy(table[x].command, "sqrt");
6060
table[x++].tok = SQRT;
61-
strcpy(table[x].command, "sqr");
61+
std::strcpy(table[x].command, "sqr");
6262
table[x++].tok = SQR;
63-
strcpy(table[x].command, "abs");
63+
std::strcpy(table[x].command, "abs");
6464
table[x++].tok = ABS;
65-
strcpy(table[x].command, "trunc");
65+
std::strcpy(table[x].command, "trunc");
6666
table[x++].tok = TRUNC;
67-
strcpy(table[x].command, "pi");
67+
std::strcpy(table[x].command, "pi");
6868
table[x++].tok = PI;
6969

70-
strcpy(table[x].command, "if");
70+
std::strcpy(table[x].command, "if");
7171
table[x++].tok = IF;
72-
strcpy(table[x].command, "then");
72+
std::strcpy(table[x].command, "then");
7373
table[x++].tok = THEN;
74-
strcpy(table[x].command, "goto");
74+
std::strcpy(table[x].command, "goto");
7575
table[x++].tok = GOTO;
76-
strcpy(table[x].command, "for");
76+
std::strcpy(table[x].command, "for");
7777
table[x++].tok = FOR;
78-
strcpy(table[x].command, "next");
78+
std::strcpy(table[x].command, "next");
7979
table[x++].tok = NEXT;
80-
strcpy(table[x].command, "to");
80+
std::strcpy(table[x].command, "to");
8181
table[x++].tok = TO;
82-
strcpy(table[x].command, "gosub");
82+
std::strcpy(table[x].command, "gosub");
8383
table[x++].tok = GOSUB;
84-
strcpy(table[x].command, "return");
84+
std::strcpy(table[x].command, "return");
8585
table[x++].tok = RETURN;
86-
strcpy(table[x].command, "end");
86+
std::strcpy(table[x].command, "end");
8787
table[x++].tok = END;
88-
strcpy(table[x].command, "");
88+
std::strcpy(table[x].command, "");
8989
table[x++].tok = END + 1;
9090
}
9191

@@ -132,12 +132,12 @@ void BasicInterpreter::exec_for()
132132

133133
get_token(); /* read the control variable */
134134

135-
if (!isalpha(*token)) {
135+
if (!std::isalpha(*token)) {
136136
serror(4);
137137
return;
138138
}
139139

140-
i.var = toupper(*token) - 'A'; /* save its index */
140+
i.var = std::toupper(*token) - 'A'; /* save its index */
141141

142142
get_token(); /* read the equals sign */
143143

@@ -221,13 +221,13 @@ int BasicInterpreter::look_up(char *s)
221221
p = s;
222222

223223
while (*p) {
224-
*p = tolower(*p);
224+
*p = std::tolower(*p);
225225
p++;
226226
}
227227

228228
/* see if token is in table */
229229
for (i = 0; *table[i].command; i++) {
230-
if (!strcmp(table[i].command, s)) {
230+
if (!std::strcmp(table[i].command, s)) {
231231
return table[i].tok;
232232
}
233233
}
@@ -238,7 +238,7 @@ int BasicInterpreter::look_up(char *s)
238238
/* Return true if c is a delimiter. */
239239
int BasicInterpreter::isdelim(char c)
240240
{
241-
if (strchr(" ;,+-<>/*%^=()", c) || c == 9 || c == '\n' || c == 0) {
241+
if (std::strchr(" ;,+-<>/*%^=()", c) || c == 9 || c == '\n' || c == 0) {
242242
return 1;
243243
}
244244

@@ -280,7 +280,7 @@ int BasicInterpreter::get_next_label(char *s)
280280
return t;
281281
}
282282

283-
if (!strcmp(label_table[t].name, s)) {
283+
if (!std::strcmp(label_table[t].name, s)) {
284284
return -2; /* dup */
285285
}
286286
}
@@ -350,7 +350,7 @@ int BasicInterpreter::get_token()
350350
return (token_type = QUOTE);
351351
}
352352

353-
if (isdigit(*prog)) {
353+
if (std::isdigit(*prog)) {
354354
/* number */
355355
while (!isdelim(*prog)) {
356356
*temp++ = *prog++;
@@ -360,7 +360,7 @@ int BasicInterpreter::get_token()
360360
return (token_type = NUMBER);
361361
}
362362

363-
if (isalpha(*prog)) {
363+
if (std::isalpha(*prog)) {
364364
/* var or command */
365365
while (!isdelim(*prog)) {
366366
*temp++ = *prog++;
@@ -394,12 +394,12 @@ void BasicInterpreter::assignment()
394394
/* get the variable name */
395395
get_token();
396396

397-
if (!isalpha(*token)) {
397+
if (!std::isalpha(*token)) {
398398
serror(4);
399399
return;
400400
}
401401

402-
var = toupper(*token) - 'A';
402+
var = std::toupper(*token) - 'A';
403403

404404
/* get the equals sign */
405405
get_token();
@@ -482,7 +482,7 @@ void BasicInterpreter::scan_labels()
482482
get_token();
483483

484484
if (token_type == NUMBER) {
485-
strcpy(label_table[0].name, token);
485+
std::strcpy(label_table[0].name, token);
486486
label_table[0].p = prog;
487487
}
488488

@@ -498,7 +498,7 @@ void BasicInterpreter::scan_labels()
498498
(addr == -1) ? serror(5) : serror(6);
499499
}
500500

501-
strcpy(label_table[addr].name, token);
501+
std::strcpy(label_table[addr].name, token);
502502
label_table[addr].p = prog; /* current point in program */
503503
}
504504

@@ -520,7 +520,7 @@ char *BasicInterpreter::find_label(char *s)
520520
int t;
521521

522522
for (t = 0; t < NUM_LAB; ++t) {
523-
if (!strcmp(label_table[t].name, s)) {
523+
if (!std::strcmp(label_table[t].name, s)) {
524524
return label_table[t].p;
525525
}
526526
}
@@ -641,12 +641,12 @@ void BasicInterpreter::exec_sin()
641641

642642
get_token(); /* read the control variable */
643643

644-
if (!isalpha(*token)) {
644+
if (!std::isalpha(*token)) {
645645
serror(4);
646646
return;
647647
}
648648

649-
i.var = toupper(*token) - 'A'; /* save its index */
649+
i.var = std::toupper(*token) - 'A'; /* save its index */
650650

651651
get_token(); /* read the equals sign */
652652

@@ -705,12 +705,12 @@ void BasicInterpreter::greturn()
705705
/* Find the value of a variable. */
706706
double BasicInterpreter::find_var(char *s)
707707
{
708-
if (!isalpha(*s)) {
708+
if (!std::isalpha(*s)) {
709709
serror(4); /* not a variable */
710710
return 0;
711711
}
712712

713-
return variables[toupper(*token) - 'A'];
713+
return variables[std::toupper(*token) - 'A'];
714714
}
715715

716716
/* Find value of number or variable. */
@@ -787,43 +787,43 @@ void BasicInterpreter::level4(double *result)
787787
case SIN:
788788
get_token();
789789
level4(&hold);
790-
*result = sin((M_PI / 180) * hold);
790+
*result = std::sin((M_PI / 180) * hold);
791791
break;
792792

793793
case COS:
794794
get_token();
795795
level4(&hold);
796-
*result = cos((M_PI / 180) * hold);
796+
*result = std::cos((M_PI / 180) * hold);
797797
break;
798798

799799
case TAN:
800800
get_token();
801801
level4(&hold);
802-
*result = tan((M_PI / 180) * hold);
802+
*result = std::tan((M_PI / 180) * hold);
803803
break;
804804

805805
case SQRT:
806806
get_token();
807807
level4(&hold);
808-
*result = sqrt(hold);
808+
*result = std::sqrt(hold);
809809
break;
810810

811811
case SQR:
812812
get_token();
813813
level4(&hold);
814-
*result = pow(hold, 2);
814+
*result = std::pow(hold, 2);
815815
break;
816816

817817
case ABS:
818818
get_token();
819819
level4(&hold);
820-
*result = abs(hold);
820+
*result = std::fabs(hold);
821821
break;
822822

823823
case TRUNC:
824824
get_token();
825825
level4(&hold);
826-
*result = trunc(hold);
826+
*result = std::trunc(hold);
827827
break;
828828

829829
case PI:
@@ -920,7 +920,7 @@ int BasicInterpreter::interpretBasic(QString &code)
920920

921921
char *buf = new char[code.toLatin1().size() + 1];
922922

923-
memcpy(buf, code.toLatin1().data(), code.toLatin1().size());
923+
std::memcpy(buf, code.toLatin1().data(), code.toLatin1().size());
924924

925925
prog = buf;
926926
scan_labels(); /* find the labels in the program */

addons/src/bhc/bhcdialog.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
// see https://learn.microsoft.com/ru-ru/cpp/c-runtime-library/math-constant
2323
#define _USE_MATH_DEFINES
2424

25-
#include <cmath> // for cos, sin, M_PI
26-
#include <cstdlib> // for abs
25+
#include <cmath> // for fabs, cos, sin, M_PI
2726

2827
#include <QCheckBox> // for QCheckBox
2928
#include <QColor> // for QColor
@@ -186,9 +185,9 @@ void BHCDialog::computeButtonClicked()
186185
}
187186

188187
maxDia = qMax(maxDia, (QLocale().toDouble(tab->diaInput->text(),
189-
&ok) + 2 * abs(QLocale().toDouble(tab->xCenterInput->text(), &ok))));
188+
&ok) + 2 * std::fabs(QLocale().toDouble(tab->xCenterInput->text(), &ok))));
190189
maxDia = qMax(maxDia, (QLocale().toDouble(tab->diaInput->text(),
191-
&ok) + 2 * abs(QLocale().toDouble(tab->yCenterInput->text(), &ok))));
190+
&ok) + 2 * std::fabs(QLocale().toDouble(tab->yCenterInput->text(), &ok))));
192191
}
193192

194193
for (tabId = 0; tabId < tabBar->count(); tabId++) {
@@ -297,8 +296,8 @@ void BHCDialog::computeButtonClicked()
297296
ang = ang + 360;
298297
}
299298

300-
x = xCenter + (dia * cos((M_PI / 180) * ang));
301-
y = yCenter + (dia * sin((M_PI / 180) * ang));
299+
x = xCenter + (dia * std::cos((M_PI / 180) * ang));
300+
y = yCenter + (dia * std::sin((M_PI / 180) * ang));
302301

303302
QTableWidgetItem* xItem = new QTableWidgetItem(Utils::removeZeros(QString("%1").arg(x, 0, 'f', 3)));
304303
xItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);

addons/src/bhc/bhcdraw.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ void BHCDraw::drawHole(qreal ang, qreal dia, qreal xcenter, qreal ycenter, bool
124124
paint->scale(sca, sca);
125125

126126
d = 12 / sca;
127-
x = xcenter + (dia + (d)) * cos((M_PI / 180) * ang);
128-
y = ycenter + (dia + (d)) * sin((M_PI / 180) * ang);
127+
x = xcenter + (dia + (d)) * std::cos((M_PI / 180) * ang);
128+
y = ycenter + (dia + (d)) * std::sin((M_PI / 180) * ang);
129129

130-
x1 = xcenter + (dia - (d)) * cos((M_PI / 180) * ang);
131-
y1 = ycenter + (dia - (d)) * sin((M_PI / 180) * ang);
130+
x1 = xcenter + (dia - (d)) * std::cos((M_PI / 180) * ang);
131+
y1 = ycenter + (dia - (d)) * std::sin((M_PI / 180) * ang);
132132

133133

134134
paint->setPen(QPen(Qt::gray, 0, Qt::DotLine));
@@ -151,10 +151,10 @@ void BHCDraw::drawHole(qreal ang, qreal dia, qreal xcenter, qreal ycenter, bool
151151
-(ycenter + v.y() / 2)));
152152

153153
//circle radius line
154-
x = xcenter + 0 * cos((M_PI / 180) * ang);
155-
y = ycenter + (0) * sin((M_PI / 180) * ang);
156-
x1 = xcenter + (dia - (d)) * cos((M_PI / 180) * ang);
157-
y1 = ycenter + (dia - (d)) * sin((M_PI / 180) * ang);
154+
x = xcenter + 0 * std::cos((M_PI / 180) * ang);
155+
y = ycenter + (0) * std::sin((M_PI / 180) * ang);
156+
x1 = xcenter + (dia - (d)) * std::cos((M_PI / 180) * ang);
157+
y1 = ycenter + (dia - (d)) * std::sin((M_PI / 180) * ang);
158158
paint->drawLine(QPointF(x, -y), QPointF(x1, -y1));
159159

160160
//diameter circle
@@ -167,8 +167,8 @@ void BHCDraw::drawHole(qreal ang, qreal dia, qreal xcenter, qreal ycenter, bool
167167
paint->setPen(QPen(color, 0, Qt::SolidLine));
168168
}
169169

170-
x = xcenter + dia * cos((M_PI / 180) * ang);
171-
y = ycenter + dia * sin((M_PI / 180) * ang);
170+
x = xcenter + dia * std::cos((M_PI / 180) * ang);
171+
y = ycenter + dia * std::sin((M_PI / 180) * ang);
172172

173173
d = 8 / sca;
174174

@@ -201,16 +201,16 @@ void BHCDraw::drawLines(qreal dia, qreal ang, QColor cl)
201201

202202
paint->setPen(QPen(cl, 0, Qt::DotLine));
203203

204-
x = (dia + 4) * cos((M_PI / 180) * ang);
205-
y = (dia + 4) * sin((M_PI / 180) * ang);
206-
x1 = (dia + 4) * cos((M_PI / 180) * (ang + 180));
207-
y1 = (dia + 4) * sin((M_PI / 180) * (ang + 180));
204+
x = (dia + 4) * std::cos((M_PI / 180) * ang);
205+
y = (dia + 4) * std::sin((M_PI / 180) * ang);
206+
x1 = (dia + 4) * std::cos((M_PI / 180) * (ang + 180));
207+
y1 = (dia + 4) * std::sin((M_PI / 180) * (ang + 180));
208208
paint->drawLine(QPointF(x, -y), QPointF(x1, -y1));
209209

210-
x = (dia + 4) * cos((M_PI / 180) * (ang + 90));
211-
y = (dia + 4) * sin((M_PI / 180) * (ang + 90));
212-
x1 = (dia + 4) * cos((M_PI / 180) * (ang + 270));
213-
y1 = (dia + 4) * sin((M_PI / 180) * (ang + 270));
210+
x = (dia + 4) * std::cos((M_PI / 180) * (ang + 90));
211+
y = (dia + 4) * std::sin((M_PI / 180) * (ang + 90));
212+
x1 = (dia + 4) * std::cos((M_PI / 180) * (ang + 270));
213+
y1 = (dia + 4) * std::sin((M_PI / 180) * (ang + 270));
214214
paint->drawLine(QPointF(x, -y), QPointF(x1, -y1));
215215

216216
paint->restore();

addons/src/chamfer/chamferdialog.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void ChamferDialog::computeButtonClicked()
106106
ang = QLocale().toDouble(angInput->text(), &ok);
107107
ZL = QLocale().toDouble(zlInput->text(), &ok);
108108

109-
XL = tan((M_PI / 180) * ang) * (ZL * 2);
109+
XL = std::tan((M_PI / 180) * ang) * (ZL * 2);
110110
dlInput->setText(QString("%1").arg(XL, 0, 'f', 3));
111111

112112
if (xoCheckBox->isChecked() && xoInput->hasAcceptableInput()) {
@@ -134,7 +134,7 @@ void ChamferDialog::computeButtonClicked()
134134
ang = QLocale().toDouble(angInput->text(), &ok);
135135
XL = QLocale().toDouble(dlInput->text(), &ok);
136136

137-
ZL = (XL / 2) / tan((M_PI / 180) * ang) ;
137+
ZL = (XL / 2) / std::tan((M_PI / 180) * ang) ;
138138
zlInput->setText(QString("%1").arg(ZL, 0, 'f', 3));
139139

140140
return;
@@ -151,7 +151,7 @@ void ChamferDialog::computeButtonClicked()
151151
X2 = QLocale().toDouble(xdInput->text(), &ok);
152152
XL = X2 - X1;
153153
dlInput->setText(QString("%1").arg(XL, 0, 'f', 3));
154-
ZL = (XL / 2) / tan((M_PI / 180) * ang) ;
154+
ZL = (XL / 2) / std::tan((M_PI / 180) * ang) ;
155155
zlInput->setText(QString("%1").arg(ZL, 0, 'f', 3));
156156

157157
return;
@@ -164,7 +164,7 @@ void ChamferDialog::computeButtonClicked()
164164

165165
XL = QLocale().toDouble(dlInput->text(), &ok);
166166
ZL = QLocale().toDouble(zlInput->text(), &ok);
167-
ang = (atan((XL / 2) / ZL)) / (M_PI / 180);
167+
ang = (std::atan((XL / 2) / ZL)) / (M_PI / 180);
168168

169169
angInput->setText(QString("%1").arg(ang, 0, 'f', 3));
170170

0 commit comments

Comments
 (0)