Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff5d8aa

Browse files
committed
Added preferences/startup options for division warning
and accepting unix-style newlines on input. Also (finally) added a startup option to get -vv behaviour. Moved __convert_to_newlines to main.c because that's easier with the newline option.
1 parent a5ffeb6 commit ff5d8aa

2 files changed

Lines changed: 37 additions & 23 deletions

File tree

Mac/Python/macglue.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -179,23 +179,6 @@ static PyObject *python_event_handler;
179179
*/
180180
int PyMac_AppearanceCompliant;
181181

182-
#ifndef WITHOUT_UNIX_NEWLINES
183-
/*
184-
** Experimental feature (for 2.2a2): allow unix newlines
185-
** as well as Mac newlines on input. We replace a lowlevel
186-
** MSL routine to accomplish this
187-
*/
188-
void
189-
__convert_to_newlines(unsigned char * buf, size_t * n_ptr)
190-
{
191-
unsigned char *p;
192-
size_t n = *n_ptr;
193-
194-
for(p=buf; n > 0; p++, n--)
195-
if ( *p == '\r' ) *p = '\n';
196-
}
197-
#endif /* WITHOUT_UNIX_NEWLINES */
198-
199182
/* Given an FSSpec, return the FSSpec of the parent folder */
200183

201184
static OSErr

Mac/Python/macmain.c

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ extern PyMac_AddLibResources(void);
6262
#define COPYRIGHT \
6363
"Type \"copyright\", \"credits\" or \"license\" for more information."
6464

65-
66-
extern int Py_DebugFlag; /* For parser.c, declared in pythonrun.c */
67-
extern int Py_VerboseFlag; /* For import.c, declared in pythonrun.c */
6865
short PyMac_AppRefNum; /* RefNum of application resource fork */
6966

7067
/* For Py_GetArgcArgv(); set by main() */
@@ -159,6 +156,7 @@ PyMac_InteractiveOptions(PyMac_PrefRecord *p, int *argcp, char ***argvp)
159156

160157
SET_OPT_ITEM(OPT_INSPECT, inspect);
161158
SET_OPT_ITEM(OPT_VERBOSE, verbose);
159+
/* OPT_VERBOSEVERBOSE is default off */
162160
SET_OPT_ITEM(OPT_OPTIMIZE, optimize);
163161
SET_OPT_ITEM(OPT_UNBUFFERED, unbuffered);
164162
SET_OPT_ITEM(OPT_DEBUGGING, debugging);
@@ -173,7 +171,8 @@ PyMac_InteractiveOptions(PyMac_PrefRecord *p, int *argcp, char ***argvp)
173171
/* SET_OPT_ITEM(OPT_KEEPCONSOLE, keep_console); */
174172
SET_OPT_ITEM(OPT_TABWARN, tabwarn);
175173
SET_OPT_ITEM(OPT_NOSITE, nosite);
176-
SET_OPT_ITEM(OPT_NONAVSERV, nonavservice);
174+
SET_OPT_ITEM(OPT_DIVISIONWARN, divisionwarn);
175+
SET_OPT_ITEM(OPT_UNIXNEWLINES, unixnewlines);
177176
/* The rest are not settable interactively */
178177

179178
#undef SET_OPT_ITEM
@@ -219,6 +218,16 @@ PyMac_InteractiveOptions(PyMac_PrefRecord *p, int *argcp, char ***argvp)
219218

220219
OPT_ITEM(OPT_INSPECT, inspect);
221220
OPT_ITEM(OPT_VERBOSE, verbose);
221+
if ( item == OPT_VERBOSEVERBOSE ) {
222+
if ( p->verbose == 2 )
223+
p->verbose = 1;
224+
else
225+
p->verbose = 2;
226+
GetDialogItem(dialog, OPT_VERBOSE, &type, (Handle *)&handle, &rect);
227+
SetControlValue(handle, 1);
228+
}
229+
GetDialogItem(dialog, OPT_VERBOSEVERBOSE, &type, (Handle *)&handle, &rect);
230+
SetControlValue(handle, p->verbose == 2);
222231
OPT_ITEM(OPT_OPTIMIZE, optimize);
223232
OPT_ITEM(OPT_UNBUFFERED, unbuffered);
224233
OPT_ITEM(OPT_DEBUGGING, debugging);
@@ -236,7 +245,8 @@ PyMac_InteractiveOptions(PyMac_PrefRecord *p, int *argcp, char ***argvp)
236245
SetControlValue(handle, (short)(p->keep_console == POPT_KEEPCONSOLE_NEVER));
237246
OPT_ITEM(OPT_TABWARN, tabwarn);
238247
OPT_ITEM(OPT_NOSITE, nosite);
239-
OPT_ITEM(OPT_NONAVSERV, nonavservice);
248+
OPT_ITEM(OPT_DIVISIONWARN, divisionwarn);
249+
OPT_ITEM(OPT_UNIXNEWLINES, unixnewlines);
240250

241251
#undef OPT_ITEM
242252
}
@@ -315,6 +325,7 @@ init_common(int *argcp, char ***argvp, int embedded)
315325
Py_DebugFlag = PyMac_options.debugging;
316326
Py_NoSiteFlag = PyMac_options.nosite;
317327
Py_TabcheckFlag = PyMac_options.tabwarn;
328+
Py_DivisionWarningFlag = PyMac_options.divisionwarn;
318329
if ( PyMac_options.noargs ) {
319330
/* don't process events at all without the scripts permission */
320331
PyMacSchedParams scp;
@@ -674,4 +685,24 @@ int
674685
PyMac_GetDelayConsoleFlag()
675686
{
676687
return (int)PyMac_options.delayconsole;
677-
}
688+
}
689+
690+
#ifndef WITHOUT_UNIX_NEWLINES
691+
/*
692+
** Experimental feature (for 2.2a2): optionally allow unix newlines
693+
** as well as Mac newlines on input. We replace a lowlevel
694+
** MSL routine to accomplish this.
695+
*/
696+
void
697+
__convert_to_newlines(unsigned char * buf, size_t * n_ptr)
698+
{
699+
unsigned char *p;
700+
size_t n = *n_ptr;
701+
702+
for(p=buf; n > 0; p++, n--)
703+
if ( *p == '\r' ) *p = '\n';
704+
else if ( *p == '\n' && !PyMac_options.unixnewlines )
705+
*p = '\r';
706+
}
707+
#endif /* WITHOUT_UNIX_NEWLINES */
708+

0 commit comments

Comments
 (0)