Skip to content

Commit

Permalink
remember scripts opened in ScriptEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulBoersma committed Nov 17, 2024
1 parent 81f4b9c commit e9a63f6
Show file tree
Hide file tree
Showing 25 changed files with 98 additions and 76 deletions.
4 changes: 2 additions & 2 deletions dwtools/LongSound_extensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ static void MelderFile_truncate (MelderFile me, integer size) {
CloseHandle (hFile);
#elif defined (linux) || defined (macintosh)
MelderFile_close (me);
const int succes = truncate (Melder_peek32to8_fileSystem (my path), size);
Melder_require (succes == 0,
const int success = truncate (Melder_peek32to8_fileSystem (my path), size);
Melder_require (success == 0,
U"Truncating failed for file ", me, U" (", Melder_peek8to32 (strerror (errno)), U").");
#else
Melder_throw (U"Don't know what to do.");
Expand Down
2 changes: 1 addition & 1 deletion dwtools/VowelEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static bool isValidVowelMarksTableFile (MelderFile file, autoTable *out_marks) {
autoDaata data = Data_readFromFile (file);
if (! Thing_isa (data.get(), classTable))
return false;
autoTable marks = data.static_cast_move <structTable> ();
autoTable marks = data.static_cast_move <structTable>();
/*
Require columns Vowel F1 and F2 to be present in the Table
*/
Expand Down
4 changes: 2 additions & 2 deletions fon/AmplitudeTier.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* AmplitudeTier.cpp
*
* Copyright (C) 2003-2012,2014-2022 Paul Boersma
* Copyright (C) 2003-2012,2014-2022,2024 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -38,7 +38,7 @@ void AmplitudeTier_draw (AmplitudeTier me, Graphics g, double tmin, double tmax,

autoAmplitudeTier PointProcess_upto_AmplitudeTier (PointProcess me, double soundPressure) {
try {
autoAmplitudeTier thee = PointProcess_upto_RealTier (me, soundPressure, classAmplitudeTier).static_cast_move<structAmplitudeTier>();
autoAmplitudeTier thee = PointProcess_upto_RealTier (me, soundPressure, classAmplitudeTier).static_cast_move <structAmplitudeTier>();
return thee;
} catch (MelderError) {
Melder_throw (me, U": not converted to AmplitudeTier.");
Expand Down
6 changes: 3 additions & 3 deletions fon/ExperimentMFC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ static void readSound (ExperimentMFC me, conststring32 fileNameHead, conststring
if (Melder_debug == 32) {
MelderInfo_open ();
MelderInfo_writeLine (U"Path name <", pathName, U">");
MelderInfo_writeLine (U"Root folder <", my rootDirectory.path, U">");
MelderInfo_writeLine (U"Full path name <", file.path, U">");
MelderInfo_writeLine (U"Root folder <", MelderFolder_peekPath (& my rootDirectory), U">");
MelderInfo_writeLine (U"Full path name <", MelderFile_peekPath (& file), U">");
MelderInfo_close ();
}
}
/*
Read the substimulus.
*/
autoSound substimulus = Data_readFromFile (& file). static_cast_move<structSound>();
autoSound substimulus = Data_readFromFile (& file).static_cast_move <structSound>();
Melder_require (substimulus -> classInfo == classSound,
U"File ", & file, U" contains a ", Thing_className (substimulus.get()), U" instead of a sound.");
/*
Expand Down
10 changes: 5 additions & 5 deletions fon/IntensityTier.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* IntensityTier.cpp
*
* Copyright (C) 1992-2005,2007,2008,2010-2012,2015-2018,2020-2022 Paul Boersma
* Copyright (C) 1992-2005,2007,2008,2010-2012,2015-2018,2020-2022,2024 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -38,7 +38,7 @@ void IntensityTier_draw (IntensityTier me, Graphics g, double tmin, double tmax,

autoIntensityTier PointProcess_upto_IntensityTier (PointProcess me, double intensity) {
try {
autoIntensityTier thee = PointProcess_upto_RealTier (me, intensity, classIntensityTier).static_cast_move<structIntensityTier>();
autoIntensityTier thee = PointProcess_upto_RealTier (me, intensity, classIntensityTier).static_cast_move <structIntensityTier>();
return thee;
} catch (MelderError) {
Melder_throw (me, U": not converted to IntensityTier.");
Expand All @@ -47,7 +47,7 @@ autoIntensityTier PointProcess_upto_IntensityTier (PointProcess me, double inten

autoIntensityTier Intensity_downto_IntensityTier (Intensity me) {
try {
autoIntensityTier thee = Vector_to_RealTier (me, 1, classIntensityTier).static_cast_move<structIntensityTier>();
autoIntensityTier thee = Vector_to_RealTier (me, 1, classIntensityTier).static_cast_move <structIntensityTier>();
return thee;
} catch (MelderError) {
Melder_throw (me, U": not converted to IntensityTier.");
Expand All @@ -56,7 +56,7 @@ autoIntensityTier Intensity_downto_IntensityTier (Intensity me) {

autoIntensityTier Intensity_to_IntensityTier_peaks (Intensity me) {
try {
autoIntensityTier thee = Vector_to_RealTier_peaks (me, 1, classIntensityTier).static_cast_move<structIntensityTier>();
autoIntensityTier thee = Vector_to_RealTier_peaks (me, 1, classIntensityTier).static_cast_move <structIntensityTier>();
return thee;
} catch (MelderError) {
Melder_throw (me, U": peaks not converted to IntensityTier.");
Expand All @@ -65,7 +65,7 @@ autoIntensityTier Intensity_to_IntensityTier_peaks (Intensity me) {

autoIntensityTier Intensity_to_IntensityTier_valleys (Intensity me) {
try {
autoIntensityTier thee = Vector_to_RealTier_valleys (me, 1, classIntensityTier).static_cast_move<structIntensityTier>();
autoIntensityTier thee = Vector_to_RealTier_valleys (me, 1, classIntensityTier).static_cast_move <structIntensityTier>();
return thee;
} catch (MelderError) {
Melder_throw (me, U": valleys not converted to IntensityTier.");
Expand Down
4 changes: 2 additions & 2 deletions fon/Ltas_to_SpectrumTier.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Ltas_to_SpectrumTier.cpp
*
* Copyright (C) 2007-2011,2015 Paul Boersma
* Copyright (C) 2007-2011,2015,2026,2024 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -20,7 +20,7 @@

autoSpectrumTier Ltas_to_SpectrumTier_peaks (Ltas me) {
try {
autoSpectrumTier thee = Vector_to_RealTier_peaks (me, 1, classSpectrumTier).static_cast_move<structSpectrumTier>();
autoSpectrumTier thee = Vector_to_RealTier_peaks (me, 1, classSpectrumTier).static_cast_move <structSpectrumTier>();
return thee;
} catch (MelderError) {
Melder_throw (me, U": peaks not analyzed as SpectrumTier.");
Expand Down
2 changes: 1 addition & 1 deletion fon/Matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ autoMatrix Matrix_readAP (MelderFile file) {

autoMatrix Matrix_appendRows (const constMatrix me, const constMatrix thee, ClassInfo klas) {
try {
autoMatrix him = Thing_newFromClass (klas).static_cast_move<structMatrix>();
autoMatrix him = Thing_newFromClass (klas).static_cast_move <structMatrix>();
Matrix_init (him.get(),
std::min (my xmin, thy xmin),
std::max (my xmax, thy xmax),
Expand Down
4 changes: 2 additions & 2 deletions fon/PitchTier.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* PitchTier.cpp
*
* Copyright (C) 1992-2008,2010-2013,2015-2018,2021,2022 Paul Boersma
* Copyright (C) 1992-2008,2010-2013,2015-2018,2021,2022,2024 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -49,7 +49,7 @@ void PitchTier_draw (PitchTier me, Graphics g, double tmin, double tmax,

autoPitchTier PointProcess_upto_PitchTier (PointProcess me, double frequency) {
try {
autoPitchTier thee = PointProcess_upto_RealTier (me, frequency, classPitchTier).static_cast_move<structPitchTier>();
autoPitchTier thee = PointProcess_upto_RealTier (me, frequency, classPitchTier).static_cast_move <structPitchTier>();
return thee;
} catch (MelderError) {
Melder_throw (me, U": not converted to PitchTier.");
Expand Down
6 changes: 3 additions & 3 deletions fon/RealTier.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* RealTier.cpp
*
* Copyright (C) 1992-2012,2014-2023 Paul Boersma
* Copyright (C) 1992-2012,2014-2024 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -85,7 +85,7 @@ autoRealTier RealTier_create (double tmin, double tmax) {

autoRealTier RealTier_createWithClass (double tmin, double tmax, ClassInfo klas) {
try {
autoRealTier me = Thing_newFromClass (klas).static_cast_move <structRealTier> ();
autoRealTier me = Thing_newFromClass (klas).static_cast_move <structRealTier>();
RealTier_init (me.get(), tmin, tmax);
return me;
} catch (MelderError) {
Expand All @@ -99,7 +99,7 @@ template <typename T> autoSomeThing <T> Thing_create () {

template <>
autoSomeThing <structRealTier> Thing_create <structRealTier> () {
return Thing_newFromClass (classRealTier). static_cast_move<structRealTier>();
return Thing_newFromClass (classRealTier).static_cast_move <structRealTier>();
}

template <typename structSomeRealTier>
Expand Down
2 changes: 1 addition & 1 deletion fon/praat_Sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2189,7 +2189,7 @@ static int recordFromFileProc (MelderFile file) {
if (last == melderSoundFromFile.get())
last = nullptr;
Melder_warningOff (); // like "missing samples"
melderSoundFromFile = Data_readFromFile (file). static_cast_move<structSound>();
melderSoundFromFile = Data_readFromFile (file).static_cast_move <structSound>();
Melder_warningOn ();
if (! melderSoundFromFile)
return 0;
Expand Down
32 changes: 14 additions & 18 deletions generate/espeak/GENERATE.praat
Original file line number Diff line number Diff line change
Expand Up @@ -320,25 +320,21 @@ After this, the folder `./src` will be empty again.
- Adapt `GetVoices()` in `voices.cpp`:
{;
#if DATA_FROM_SOURCECODE_FILES /* ppgb: whole function adapted to Praat */
/*
If is_languange_file == 0 then /voices/ else /lang/.
We know that our voices are in /voices/ (actually in /voices/!v/) and our languages in /lang/.
*/
(void) path;
FileInMemorySet me = theEspeakPraatFileInMemorySet();
conststring32 criterion = ( is_language_file ? U"/lang/" : U"/voices/" );
autoFileInMemorySet fileList = FileInMemorySet_listFiles (me, kMelder_string :: CONTAINS, criterion);
for (long ifile = 1; ifile <= fileList -> size; ifile ++) {
FileInMemory fim = fileList -> at [ifile];
FileInMemory f_voice = FileInMemorySet_fopen (me, Melder_peek32to8_fileSystem (fim -> string.get()), "r");
conststring8 fname = Melder_peek32to8_fileSystem (fim -> string.get());
espeak_VOICE *voice_data = ReadVoiceFile (f_voice, fname + len_path_voices, is_language_file);
FileInMemory_fclose (f_voice);
if (voice_data) {
voices_list [n_voices_list ++] = voice_data;
} /*else {
Melder_warning (U"Voice data for ", fname, U" could not be gathered.");
}*/
static MelderString criterion;
MelderString_copy (& criterion, Melder_peek8to32 (path));
MelderString_appendCharacter (& criterion, PATHSEP);
Melder_assert (criterion.length == len_path_voices); // sanity check
for (long ifile = 1; ifile <= my size; ifile ++) {
FileInMemory fim = my at [ifile];
if (Melder_stringMatchesCriterion (fim -> string.get(), kMelder_string :: STARTS_WITH, criterion.string, true)) {
FileInMemory f_voice = FileInMemory_fopen (fim, "r");
conststring8 fname = Melder_peek32to8_fileSystem (fim -> string.get());
espeak_VOICE *voice_data = ReadVoiceFile (f_voice, fname + len_path_voices, is_language_file);
FileInMemory_fclose (f_voice);
if (voice_data)
voices_list [n_voices_list ++] = voice_data;
}
}
#else /* ppgb: the original code, which uses opendir: */
char fname[sizeof(path_home)+100];
Expand Down
34 changes: 18 additions & 16 deletions melder/melder_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ FILE * Melder_fopen (MelderFile file, const char *type) {
} else {
//TRACE
#if defined (_WIN32) && ! defined (__CYGWIN__)
f = _wfopen (Melder_peek32toW_fileSystem (file -> path), Melder_peek32toW (Melder_peek8to32 (type)));
f = _wfopen (MelderFile_peekPathW (file), Melder_peek32toW (Melder_peek8to32 (type)));
#else
struct stat statbuf;
int status = stat ((char *) utf8path, & statbuf);
Expand Down Expand Up @@ -698,12 +698,12 @@ void Melder_fclose (MelderFile file, FILE *f) {
bool MelderFile_exists (MelderFile file) {
#if defined (UNIX)
struct stat fileOrFolderStatus;
const bool exists = ( stat (Melder_peek32to8_fileSystem (file -> path), & fileOrFolderStatus) == 0 );
const bool exists = ( stat (MelderFile_peekPath8 (file), & fileOrFolderStatus) == 0 );
if (! exists)
return false;
return ! S_ISDIR (fileOrFolderStatus. st_mode);
#else
DWORD fileOrFolderAttributes = GetFileAttributesW (Melder_peek32toW_fileSystem (file -> path));
DWORD fileOrFolderAttributes = GetFileAttributesW (MelderFile_peekPathW (file));
if (fileOrFolderAttributes == INVALID_FILE_ATTRIBUTES)
return false;
return (fileOrFolderAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0;
Expand All @@ -713,12 +713,12 @@ bool MelderFile_exists (MelderFile file) {
bool MelderFolder_exists (MelderFolder folder) {
#if defined (UNIX)
struct stat fileOrFolderStatus;
const bool exists = ( stat (Melder_peek32to8_fileSystem (folder -> path), & fileOrFolderStatus) == 0 );
const bool exists = ( stat (MelderFolder_peekPath8 (folder), & fileOrFolderStatus) == 0 );
if (! exists)
return false;
return S_ISDIR (fileOrFolderStatus. st_mode);
#else
DWORD fileOrFolderAttributes = GetFileAttributesW (Melder_peek32toW_fileSystem (folder -> path));
DWORD fileOrFolderAttributes = GetFileAttributesW (MelderFolder_peekPathW (folder));
if (fileOrFolderAttributes == INVALID_FILE_ATTRIBUTES)
return false;
return (fileOrFolderAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
Expand Down Expand Up @@ -761,7 +761,7 @@ bool Melder_tryToAppendFile (MelderFile file) {
integer MelderFile_length (MelderFile file) {
#if defined (UNIX)
struct stat statistics;
if (stat (Melder_peek32to8_fileSystem (file -> path), & statistics) != 0)
if (stat (MelderFile_peekPath8 (file), & statistics) != 0)
return -1;
return statistics. st_size;
#else
Expand All @@ -779,18 +779,20 @@ integer MelderFile_length (MelderFile file) {
}

void MelderFile_delete (MelderFile file) {
if (! file) return;
if (! file)
return;
#if defined (UNIX)
remove (Melder_peek32to8_fileSystem (file -> path));
remove (MelderFile_peekPath8 (file));
#elif defined (_WIN32)
DeleteFile (Melder_peek32toW_fileSystem (file -> path));
DeleteFile (MelderFile_peekPathW (file));
#endif
}

char32 * Melder_peekExpandBackslashes (conststring32 message) {
static char32 names [11] [kMelder_MAXPATH+1];
static int index = 0;
if (++ index == 11) index = 0;
if (++ index == 11)
index = 0;
char32 *to = & names [index] [0];
for (const char32 *from = & message [0]; *from != '\0'; from ++, to ++) {
*to = *from;
Expand Down Expand Up @@ -839,10 +841,10 @@ void Melder_getCurrentFolder (MelderFolder folder) {

void Melder_setCurrentFolder (MelderFolder folder) {
#if defined (UNIX)
chdir (Melder_peek32to8_fileSystem (folder -> path));
chdir (MelderFolder_peekPath8 (folder));
str32cpy (theDefaultDir. path, folder -> path);
#elif defined (_WIN32)
SetCurrentDirectory (Melder_peek32toW_fileSystem (folder -> path));
SetCurrentDirectory (MelderFolder_peekPathW (folder));
#endif
}

Expand All @@ -862,7 +864,7 @@ void Melder_createDirectory (MelderFolder parent, conststring32 folderName, int
} else {
Melder_sprint (file. path,kMelder_MAXPATH+1, parent -> path, U"/", folderName); // relative path
}
if (mkdir (Melder_peek32to8_fileSystem (file. path), mode) == -1 && errno != EEXIST) // ignore if folder already exists
if (mkdir (MelderFile_peekPath8 (& file), mode) == -1 && errno != EEXIST) // ignore if folder already exists
Melder_throw (U"Cannot create directory ", & file, U".");
#elif defined (_WIN32)
structMelderFile file { };
Expand All @@ -876,7 +878,7 @@ void Melder_createDirectory (MelderFolder parent, conststring32 folderName, int
} else {
Melder_sprint (file. path,kMelder_MAXPATH+1, parent -> path, U"/", folderName); // relative path
}
if (! CreateDirectoryW (Melder_peek32toW_fileSystem (file. path), & sa) && GetLastError () != ERROR_ALREADY_EXISTS) // ignore if folder already exists
if (! CreateDirectoryW (MelderFile_peekPathW (& file), & sa) && GetLastError () != ERROR_ALREADY_EXISTS) // ignore if folder already exists
Melder_throw (U"Cannot create directory ", & file, U".");
#else
//#error Unsupported operating system.
Expand All @@ -885,7 +887,7 @@ void Melder_createDirectory (MelderFolder parent, conststring32 folderName, int

void MelderFolder_create (MelderFolder folder) {
#if defined (UNIX)
const int status = mkdir (Melder_peek32to8_fileSystem (folder -> path), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
const int status = mkdir (MelderFolder_peekPath8 (folder), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
if (status == 0)
return; // successfully created a new folder
if (errno == EEXIST)
Expand All @@ -896,7 +898,7 @@ void MelderFolder_create (MelderFolder folder) {
securityAttributes. nLength = sizeof (SECURITY_ATTRIBUTES);
securityAttributes. lpSecurityDescriptor = nullptr;
securityAttributes. bInheritHandle = false;
const int status = CreateDirectoryW (Melder_peek32toW_fileSystem (folder -> path), & securityAttributes);
const int status = CreateDirectoryW (MelderFolder_peekPathW (folder), & securityAttributes);
if (status != 0)
return; // successfully created a new folder
if (GetLastError () == ERROR_ALREADY_EXISTS)
Expand Down
2 changes: 1 addition & 1 deletion melder/melder_textencoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define _melder_textencoding_h_
/* melder_textencoding.h
*
* Copyright (C) 1992-2020,2022 Paul Boersma
* Copyright (C) 1992-2020,2022,2024 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
6 changes: 3 additions & 3 deletions stat/Distributions.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Distributions.cpp
*
* Copyright (C) 1997-2012,2014-2018,2022 Paul Boersma
* Copyright (C) 1997-2012,2014-2018,2022,2024 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -130,7 +130,7 @@ static void unicize (Distributions me) {

autoDistributions Distributions_addTwo (Distributions me, Distributions thee) {
try {
autoDistributions him = TablesOfReal_append (me, thee).static_cast_move<structDistributions>();
autoDistributions him = TablesOfReal_append (me, thee).static_cast_move <structDistributions>();
TableOfReal_sortByLabel (him.get(), 0, 0);
unicize (him.get());
return him;
Expand All @@ -141,7 +141,7 @@ autoDistributions Distributions_addTwo (Distributions me, Distributions thee) {

autoDistributions Distributions_addMany (OrderedOf<structDistributions>* me) {
try {
autoDistributions thee = TablesOfReal_appendMany ((OrderedOf<structTableOfReal>*) me).static_cast_move<structDistributions>(); // FIXME cast
autoDistributions thee = TablesOfReal_appendMany ((OrderedOf<structTableOfReal>*) me).static_cast_move <structDistributions>(); // FIXME cast
TableOfReal_sortByLabel (thee.get(), 0, 0);
unicize (thee.get());
return thee;
Expand Down
2 changes: 1 addition & 1 deletion stat/TableOfReal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ autoTableOfReal TablesOfReal_appendMany (OrderedOf<structTableOfReal>* me) {
if (thy numberOfColumns != numberOfColumns)
Melder_throw (U"Numbers of columns do not match.");
}
autoTableOfReal him = Thing_newFromClass (thy classInfo).static_cast_move <structTableOfReal> ();
autoTableOfReal him = Thing_newFromClass (thy classInfo).static_cast_move <structTableOfReal>();
TableOfReal_init (him.get(), totalNumberOfRows, numberOfColumns);
/* Unsafe: new attributes not initialized. */
for (integer icol = 1; icol <= numberOfColumns; icol ++)
Expand Down
Loading

0 comments on commit e9a63f6

Please sign in to comment.