Skip to content

Commit

Permalink
8301254: UNIX sun/font coding does not detect SuSE in openSUSE Leap d…
Browse files Browse the repository at this point in the history
…istribution

Reviewed-by: prr
  • Loading branch information
Alexander Scherbatiy committed Mar 6, 2023
1 parent 3eff1a0 commit 15c76e4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
22 changes: 14 additions & 8 deletions src/java.desktop/unix/classes/sun/font/FcFontConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,13 @@ private String getVersionString(File f) {
return null;
}

private String extractOsInfo(String s) {
private String extractInfo(String s) {
if (s == null) {
return null;
}
if (s.startsWith("\"")) s = s.substring(1);
if (s.endsWith("\"")) s = s.substring(0, s.length()-1);
s = s.replace(' ', '_');
return s;
}

Expand All @@ -323,8 +327,8 @@ protected void setOsNameAndVersion() {
try (FileInputStream fis = new FileInputStream(f)) {
props.load(fis);
}
osName = props.getProperty("DISTRIB_ID");
osVersion = props.getProperty("DISTRIB_RELEASE");
osName = extractInfo(props.getProperty("DISTRIB_ID"));
osVersion = extractInfo(props.getProperty("DISTRIB_RELEASE"));
} else if ((f = new File("/etc/redhat-release")).canRead()) {
osName = "RedHat";
osVersion = getVersionString(f);
Expand All @@ -342,11 +346,13 @@ protected void setOsNameAndVersion() {
try (FileInputStream fis = new FileInputStream(f)) {
props.load(fis);
}
osName = props.getProperty("NAME");
osVersion = props.getProperty("VERSION_ID");
osName = extractOsInfo(osName);
if (osName.equals("SLES")) osName = "SuSE";
osVersion = extractOsInfo(osVersion);
osName = extractInfo(props.getProperty("NAME"));
osVersion = extractInfo(props.getProperty("VERSION_ID"));
if (osName.equals("SLES")) {
osName = "SuSE";
} else {
osName = extractInfo(props.getProperty("ID"));
}
}
} catch (Exception e) {
if (FontUtilities.debugFonts()) {
Expand Down
22 changes: 14 additions & 8 deletions src/java.desktop/unix/classes/sun/font/MFontConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,20 @@ protected void setOsNameAndVersion(){
try (FileInputStream fis = new FileInputStream(f)) {
props.load(fis);
}
osName = props.getProperty("DISTRIB_ID");
osVersion = props.getProperty("DISTRIB_RELEASE");
osName = extractInfo(props.getProperty("DISTRIB_ID"));
osVersion = extractInfo(props.getProperty("DISTRIB_RELEASE"));
} else if ((f = new File("/etc/os-release")).canRead()) {
Properties props = new Properties();
try (FileInputStream fis = new FileInputStream(f)) {
props.load(fis);
}
osName = props.getProperty("NAME");
osVersion = props.getProperty("VERSION_ID");
osName = extractOsInfo(osName);
if (osName.equals("SLES")) osName = "SuSE";
osVersion = extractOsInfo(osVersion);
osName = extractInfo(props.getProperty("NAME"));
osVersion = extractInfo(props.getProperty("VERSION_ID"));
if (osName.equals("SLES")) {
osName = "SuSE";
} else {
osName = extractInfo(props.getProperty("ID"));
}
}
} catch (Exception e) {
}
Expand All @@ -143,9 +145,13 @@ private String getVersionString(File f){
return null;
}

private String extractOsInfo(String s) {
private String extractInfo(String s) {
if (s == null) {
return null;
}
if (s.startsWith("\"")) s = s.substring(1);
if (s.endsWith("\"")) s = s.substring(0, s.length()-1);
s = s.replace(' ', '_');
return s;
}

Expand Down

1 comment on commit 15c76e4

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.